Another AR relation question

Im sorry if you already heard this question, but I havent found an answer that helpt me work it out.

I have three models: itool, itoolLoan and project, is it possible to retrieve a Project.projectLocation from itool controller through itoolloan?

I have relations between each modell

ITool HAS_MANY IToolLoan

IToolLoan BELONGS_TO Project

I have tried like this but it doesn´t work:

Is it possible to go trough IToolLoan model to retrive a project attribute? or is my attached databasemodel badly written?

// Mattias


Then, $itoolList[0]->loan->project will give you what you want.

ok, nice to hear that it should work :)

But I don´t manage it to work with $itoolList[0]

This i a part of my view and this apparently doesn´t work, but could you give me some pointers how I should do?

What is the problem now?

The errormessage is:

Trying to get property of non-object

And the logged sql is like this:


any idea?

It could be that $model->loan or $model->loan->project is null. You may need to check the existence of related objects, depending on your data.