Retrieving data from the MySQL database using PHP - time management -


i need on how get/display informations db (mysql)

my current table looks this:

id | title | level | start_afterid | days |   1  |     |   0   |       0       |   7  | 2  |   b   |   1   |       1       |   5  | 3  |   c   |   1   |       2       |   3  | 4  |   d   |   1   |       3       |   2  | 5  |   e   |   1   |       4       |   2  | 6  |   f   |   1   |       3       |   6  | 

level '0' means job start first , start day , time in other table ($config_start)

all others entry level = 1 don't have fixed start, id of job (start_afterid) after start.

also every job last in number of days days field.

in table job id 6 (title f) must start after jobid 3 - , start time like:

$config_start + jobid 3 + jobid 2; 

$end of job is:

$config_start + jobid 3 + jobid 2 + 6; 

at end, need display jobs db in incoming order.

i tried best this, can't figure how check parent levels , calculate it. also, can create new administration , maybe there better way of inserting new jobs ?

thanks on this,

first of all, advise rethink level column - iiuc boolea, telling wether job root or not - information prsent in start_afterid being 0.

now calculating start , end times non-trivial job, requires lots of db avvess, advise create second table id|startday|endday , move calculation logic in way, (essentially cache) table updated on job change, leaving fast query path normal operations.

to calculate contents of timing table, like

function docalc($after,$startday) {      $sql="select * tablename start_afterid=$after";      //run query, depends on framework used      //pseudocode here - again depends on framework     foreach ($row) {         $id=$row['id'];         $endday=$startday+$row['days']; //this not simple addition, depending on data types          //adapt following data types         $sql="replace timingcache set id=$id, startday=$startday, endday=$endday";         //run query - depends on framework          docalc($id,$endday);      } //for each row  }   //this assumes $config_start set correctly docalc(0,$config_start); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -