php - RedBean multi table join -


i'm using redbean create time sheet application.

here (simplified) db structure:

owner

  • id
  • name
  • email

project

  • id
  • description
  • owner_id

task

  • id
  • description
  • project_id

log

  • id
  • start
  • end
  • description
  • task_id

the table structure far more complicated above should enough demonstrate issue.

there hundreds of log items in task , hundreds of tasks in project.

so if wanted log items specific owner , associated tasks , projects along how achieve that?

to use sql query data straight forward enough, can choose data want etc if modify data need create beans it. of tables have similar column names redbean wont (or doesn't seem magically) convert data beans.

so guess question how construct redbean query, get, getall, fetch, load etc convert data uses each join bean?

the closest thing can find traverse method means id recursively go each bean find its' children means returning whole result set , processing it.

if fastest way run sql query , iterate though data , create beans no problem. i'm doing already, wanted more abstracted way , consider redbean might offer functionality.

just give idea can use mysql joins need using r::getall(); e.g.

$result = getall("select l.*,  logs l, tasks t, projects p, owner o  l.task_id = t.id , t.project_id = p.id , p.owner_id = o.id");  $myresult = r::converttobeans('myresult', $result);  

r::converttobeans convert results bean can traversed.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -