2017-12-13 13 views
1

私はyii1を初めて使っています。私はこの質問をyii2に変換したいと思います。 yii2の条件とパラメータの違いを知ることができますか?yii1からyii2への変換

$criteria = new CDbCriteria(); 
$criteria->select = 'amount, name, level'; 
$criteria->condition = "account_type = :account_type"; 
$criteria->params=(array(':account_type'=>'credit')); 
$result = $this->model()->find($criteria); 

私は以下のサンプルを試しました。しかし、それは私にyii1クエリーと同じリターンを与えていません。

$result = Model::find() 
      ->select(['amount, name, level']) 
      ->where(['account_type' => $account_type, 'account_type' => 'credit']) 
      ->one(); 
+0

'$のaccount_type'で何ですか? –

答えて

0

これを試してみてください:

$result = Model::find() 
     ->select(['amount, name, level']) 
     ->where(['account_type' => 'credit']) 
     ->one(); 
関連する問題