无法通过为Yii中的每个属性指定值来保存模型
错误说明:无法将stdClass类型的对象用作中的数组 有人能给我解释一下为什么会发生这个错误吗?我不熟悉yii使用以下语法:无法通过为Yii中的每个属性指定值来保存模型,yii,Yii,错误说明:无法将stdClass类型的对象用作中的数组 有人能给我解释一下为什么会发生这个错误吗?我不熟悉yii使用以下语法: $model=new TestModel; $data = $_GET['data']; //get json object from ajax request $record = json_decode($data); //convert json to objects $model->
$model=new TestModel;
$data = $_GET['data']; //get json object from ajax request
$record = json_decode($data); //convert json to objects
$model->url = $record['info']['bg']; //assign url
$model->user_id = 123; //assign user id
$model->save();
$record = json_decode($data, true);
mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )
使用以下语法:
$record = json_decode($data, true);
mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0 ]]] )
默认情况下,生成对象而不是数组。使用
json\u decode($data,true)
获取数组。@DCoder:请回答,以便我可以将您的回答标记为已回答:-)默认情况下生成对象,而不是数组。使用json\u decode($data,true)
获取数组。@DCoder:请回答,以便我可以将您的回答标记为已回答:-)