问题描述
public static function primaryKey(){
return ['id_cod'];
}
我将其从模型规则中删除。
当我保存模型时,所有数据都保存在包含id_cod
的数据库中,但是,如果我尝试访问此属性,它将为空。
$evento = new Evento();
//populate the model with some data
//..... eg: $evento->name = 'name';
//save model
$evento->save();
$evento->refresh();
echo Yii::$app->db->getLastInsertID(); // gives me the correct id_cod but i think it's not the correct way
echo $evento->id_cod;//gives me null
echo $evento->name;//gives me name
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)