W
W
warcevil2016-12-01 11:40:29
Yii
warcevil, 2016-12-01 11:40:29

How to select records from tables in YII2?

Help plz! Such business that at selection from the table, the class does not write down values ​​in properties.
object(app\models\Menu)#73 (10) { ["menuid"]=> NULL ["menuname"]=> NULL ["_attributes":"yii\db\BaseActiveRecord":private]=> array(2 ) { ["MenuID"]=> int(1) ["MenuName"]=> string(23) "Children's menu" } ["_oldAttributes":"yii\db\BaseActiveRecord":private]=> array(2) { ["MenuID"]=> int(1) ["MenuName"]=> string(23) "Kids menu" } ["_related":"yii\db\BaseActiveRecord":private]=> array(0) { } ["_errors":"yii\base\Model":private]=> NULL ["_validators":"yii\base\Model":private]=> NULL ["_scenario":"
{
public $menuid;
public $menuname;
public static function tableName()
{
return 'Menu';
}
}
$items = Menu::find()->one();
var_dump($items);
Tell me what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-12-01
@slo_nik

Good morning.

$items = Menu::find()->all();
// или
$items = Menu::findAll();
var_dump($items);

That model code, what else is in it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question