views:

51

answers:

1

Hi I need to do something like this:

$hours->task->job->where('group_id' , '=' , $num)->find_all();

This would return job information. Is there any way to tell orm to return the information from the $hours table instead?

A: 

First of all, your basic PHP is wrong.

Also, make sure the plurality is accurate in the chaining:

$task->jobs assumes that task has a one to many relationship with jobs. You can't use find_all unless it does.

That would be defined in your Model.

Try:

$task = ORM::factory( 'task' , $some_task_id );

$hours = $task->jobs->where( 'group_id', '=', $num )->find_all();

This assumes that the 'group_id' value is a column in the job Model.

Hope this helps a little. Add comments if you need more help.

brennanag
This would still return the jobs table. I want a return of the tasks table. I think the best way to do it is with a join.
Navetz