Hi
I’m coming across an odd situation and I’m not sure what I’ve done wrong. my all()
call when finding models returns model information, not the data. I can see in the debugger the SQL generated and I can run it directly in TOAD and it works as expected.
Here is the code
$subQuery = new Query();
$subQuery->select(new Expression("1"))
->from('SITE HCPS')
->where(['HCPS.ID' => new Expression('A.ASSMT_PRO_ID')])
->andWhere(['A.DEL_DT' => null])
->andWhere(['HCPS.DEL_DT' => null])
->andWhere(['HCPS.PRIMARY_IND' => 'Y']);
$people = VtAssmt::find()->alias('A')
->select([new Expression("DISTINCT(H.FIRST_NAME || ' ' || H.LAST_NAME) AS NAME")])
->innerJoinWith('ProH H')
->where(['A.DEL_DT' => null])
->andWhere(['between', 'TRUNC(A.ENTERED_DT)',
new Expression("TRUNC(TO_DATE('" . $quarterStartDate . "', 'YYYYMMDD'))"),
new Expression("TRUNC(TO_DATE('" . $quarterEndDate . "', 'YYYYMMDD'))"),
])
->andWhere(['not exists', $subQuery])
->all();
But what’s returned is:
array (size=1)
0 =>
object(app\models\views\VtAssmt)[176]
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=0)
...
Not the data that the raw query generates, so what did I do wrong here? Is it that I’m mixing AR and QB?
Update
I just converted the subQuery to an AR record too and I’m finding the same out