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']);
}

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM