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