E
E
EVOSandru62015-03-30 08:41:47
Yii
EVOSandru6, 2015-03-30 08:41:47

How to push a model object to an array of similar models in Yi?

Hello,
This is the situation.
There is:
// array of objects
$model = Product::model()->findAll();
AND
// object Tried like this: But with foreach I got an error: Fatal error: Call to a member function children() on a non-object in X:\home\tasty\www\protected\views\product \all.php on line 44 assigned the element somehow incorrectly. Help advice!
$other_model = Product::model()->findByPk(5);
$model[] = $other_model;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2015-03-30
@EVOSandru6

$other_model may be null.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question