$Ticket = Ticket::find()->where("typeId=$id");
echo "<pre>";
var_dump($Ticket);
打印出来的:
object(yii\db\ActiveQuery)#58 (27) {
["sql"]=>
NULL
["on"]=>
NULL
["joinWith"]=>
NULL
["select"]=>
NULL
["selectOption"]=>
NULL
["distinct"]=>
NULL
["from"]=>
NULL
["groupBy"]=>
NULL
["join"]=>
NULL
["having"]=>
NULL
["union"]=>
NULL
["params"]=>
array(0) {
}
["_events":"yii\base\Component":private]=>
array(0) {
}
["_behaviors":"yii\base\Component":private]=>
array(0) {
}
["where"]=>
string(9) "typeId=42"
["limit"]=>
NULL
["offset"]=>
NULL
["orderBy"]=>
NULL
["indexBy"]=>
NULL
["modelClass"]=>
string(21) "backend\models\Ticket"
["with"]=>
NULL
["asArray"]=>
NULL
["multiple"]=>
NULL
["primaryModel"]=>
NULL
["link"]=>
NULL
["via"]=>
NULL
["inverseOf"]=>
NULL
}
$Ticket = Ticket::find()->where("typeId=$id")->asArray()->all();
用静态方法 findOne 你这个只是得到一个模型实例
你首先要查询出来数据,然后才可以打印哦
查询数据的方法$Ticket = Ticket::find()->where("typeId=$id")->asArray()->all();
查询多条$Ticket = Ticket::find()->where("typeId=$id")->one();
查询单条