Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2: findone() syntax on multiple where condition

Tags:

php

mysql

yii2

I have a table ipd_charges with columns

table - 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

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.

like image 338
Pawan Avatar asked Dec 14 '14 08:12

Pawan


Video Answer


1 Answers

Please check below code :

$ipdCharges = new IpdCharges();
$ipdCharges->findOne(['doctor' => $id, 'room_category' => $this->room_name]);
like image 91
toanlb Avatar answered Nov 01 '22 15:11

toanlb