為什么關聯之后只能輸出第二張表的內容
<?php?namespace?app\controllers; ????header("content-type:text/html;charset=utf8"); ????use?Yii; ????use?yii\web\Controller; ????//?引入數據模型 ????use?app\models\Test; ????use?app\models\Content; ????class?HelloController?extends?Controller{ ????????//?關聯查詢 ????????public?function?actionIndex(){ ????????????$content=Content::find()->where(["test_id"=>2])->one();???? ????????????$res=$content->hasMany("app\models\Test",["id"=>"test_id"])->asArray()->all(); ????????} ????} ?>
我是想通過content表中的test_id來關聯查詢test表中的內容,但最后$orders得到的結果只是test表中的內容,而不是兩張表結合在一起的內容
2016-01-07