為什么關(guān)聯(lián)之后只能輸出第二張表的內(nèi)容
<?php?namespace?app\controllers; ????header("content-type:text/html;charset=utf8"); ????use?Yii; ????use?yii\web\Controller; ????//?引入數(shù)據(jù)模型 ????use?app\models\Test; ????use?app\models\Content; ????class?HelloController?extends?Controller{ ????????//?關(guān)聯(lián)查詢 ????????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來關(guān)聯(lián)查詢test表中的內(nèi)容,但最后$orders得到的結(jié)果只是test表中的內(nèi)容,而不是兩張表結(jié)合在一起的內(nèi)容
2016-01-07