Hi,
In Yii 1 you could generate a model instance from a string eg
$modelName = 'Page';
$id = 1;
$model = CActiveRecord::model($modelName)->findByPk($id);
in Yii2 I can’t find an equivalent to the model method - does anyone how to do this?
Many thanks!
phtamas
(Phtamas)
2
$modelName = 'app\models\Page';
$modelName::findOne($id);
doh, that was easy lol - many thanks!
Thanks Timmy - have been through the docs - just getting a bit tangled up with how things were done in the old days 