php Yii2:多个 where 条件下的 findone() 语法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27467559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:23:35  来源:igfitidea点击:

Yii2: findone() syntax on multiple where condition

phpmysqlyii2

提问by Pawan

I have a table ipd_charges with columns

我有一个带有列的表 ipd_charges

table - ipd_charges

表 - ipd_charges

id    doctor room_category charges_cash charges_cashless
1        1          1              200            300
2        1          2              300            400

table - patient_admission

表 - 患者入院

id patient_name tpa_name(if not null, equivalent to charges_cashless)
1        1        Null
2        2         1

table daily_ward_entry

表daily_ward_entry

id  patient_name  room_name  doctor_name charges ( from ipd charges)
1          1           1           1         200
2          2           2           1         400

I am trying to use this query which is failing:

我正在尝试使用这个失败的查询:

$model = \app\models\IpdCharges::find()
         ->where(['doctor'=>$id])
         ->andwhere(['room_category'=>$this->room_name])->one();

Thanks. Please tell me if any more info is needed.

谢谢。请告诉我是否需要更多信息。

A help will be greatly appreciated.

将不胜感激。

回答by toanlb

Please check below code :

请检查以下代码:

$ipdCharges = new IpdCharges();
$ipdCharges->findOne(['doctor' => $id, 'room_category' => $this->room_name]);