Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Cant access properties in related model
I have a model with three related models. (I'm building a formula)
I get my model with
$formula_list = Model_Formula::find('first', array(
'where' => array(
'related' => array(
Models comes back ok I can print it var dump it etc I can use print_r($formula_list->operatorformulas); etc etc and get an object with two or three operator models. Perfect...
However if I then use
foreach ($formula_list->operatorformulas as $operator_model)
I get ErrorException [ Notice ]: Trying to get property of non-object. The error is on that line, not anything within the foreach but on that $formula_list->operatorformulas entity.
I've checked my models and my database all seem ok.
This works if my formula only has instances of operatorformula and field formula but fails when using metric formula although the db tables and the models are the same.
Anyone had anything like this or can thing of where I moight be going wrong?
I just dont understand why it will print the related models but not iterate through them.
It's strange, if print_r($formula_list->operatorformulas) work, i don't see why you have an error on your foreach..
Have you tried :
$operatorformulas = $formula_list->operatorformulas;
foreach($operatorformulas as $operator_model)
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion