PHP--yii中findOne转换成数组

$res = News::findOne($new_id)->toArray();

yii框架的多表联查:
controller层:

//news 与 news_theme 是多对一的关系
$infomsg=News::find()->with('newstheme')->asArray()->all();

model层:News

//news 与 news_theme 进行两表联查 多对一
public function getNewstheme()
{
return $this->hasOne(NewsTheme::className(), ['id' => 'news_theme_id']);
}

 

 

 

 
posted @ 2016-06-28 14:55  不解凡忧  Views(3886)  Comments(0Edit  收藏  举报