Reputation: 436
In my project there is a Yii2 gridview. I have a contacts table and modified is the column in it which is date field when I search for a date in that column It gives error
Integrity constraint violation – yii\db\IntegrityException
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'modified' in where clause is ambiguous
The SQL being executed was: SELECT COUNT(*) FROM `contacts` LEFT JOIN `companies` ON `contacts`.`company_id` = `companies`.`id` INNER JOIN `countries` ON `contacts`.`country` = `countries`.`country_code` WHERE (`modified`='2017') AND (`modified` LIKE '%2017%')
If I replace the code from
$query->andFilterWhere([
...
'modified' => $this->modified,
...
]);
to this code
$query->andFilterWhere([
...
'contacts.modified' => $this->modified,
...
]);
If I change the code as given above,It neither gives error nor the result.. I cant understand where I am going wrong?
Upvotes: 0
Views: 539