I have two tables, lets say images and keywords.
There is a HAS_MANY relation between them.
The keyword table consists of this:
If I call in yii something like :
Show all Images where keyword = "1234"
it works as expected.
But I need to call something like
Show all Images where keyword = "1234" AND keyword = "asdf"
Then no result is returned (but there are images with both keywords).
My query will be in the end very dynamic, so I do not know how many keywords will be called in the query.
Any ideas how to achieve this?
I have checked the output of the log files.
The SQL which yii generates looks fine, but it also gives no result directly run in MYSQL.
This is the query:
SELECT `t`.`id` AS `t0_c0`, `t`.`id_image` AS `t0_c1`, `t`.`image_number` AS `t0_c2`, `t`.`keyword` AS `t0_c40`, `imageKeywords`.`id` AS `t1_c0`, `imageKeywords`.`image_id` AS `t1_c1`, `imageKeywords`.`keyword_id` AS `t1_c2` FROM `image` `t` LEFT OUTER JOIN `image_keyword` `imageKeywords` ON (`imageKeywords`.`image_id`=`t`.`id`) WHERE (`imageKeywords`.`keyword_id`=189) AND (`imageKeywords`.`keyword_id`=152)
I am lost.