Hi,
I have a little problem with my ActiveRecords.
I want all tags containing an ‘A’ :
I do this :
$request = new TDbCriteria();
$request->condition = "tags.type = :type AND tags.id_ugc NOT IN (SELECT id_ugc_target FROM '.$tagRelTableName.' GROUP BY id_ugc_target) AND translations.text LIKE '%A%'";
$request->params = array(':type' => $type);
$numberOfResult = Tag::model()->with('translations' => array('alias'=>'translations'))->count($request);
$tags = Tag::model()->with('translations' => array('alias'=>'translations'))->findAll($request);
But there is an error :
TDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'translations.text' in 'where clause'.
My SQL log are :
Apr 20 14:24:33 [Debug] [System.Testing.Data.TDbCommand] Querying SQL: SELECT COUNT(DISTINCT `tags`.`id`) FROM `tags` LEFT OUTER JOIN `tag_i18n` translations ON (translations.`id_tag`=`tags`.`id`) AND (translations.locales LIKE '%fr_FR%') WHERE (tags.type = :type AND tags.id_ugc NOT IN (SELECT id_ugc_target FROM tag_relations GROUP BY id_ugc_target) AND translations.text LIKE '%a%') (line 308, D:\Workspace\myQuizz\trunk\server\protected\lib\prado-lib\Testing\Data\TDbCommand.php)
Apr 20 14:24:33 [Debug] [System.Testing.Data.TDbCommand] Querying SQL: SELECT `tags`.`id` AS `t0_c0`, `tags`.`type` AS `t0_c1`, `tags`.`id_ugc` AS `t0_c2` FROM `tags` WHERE (tags.type = :type AND tags.id_ugc NOT IN (SELECT id_ugc_target FROM tag_relations GROUP BY id_ugc_target) AND translations.text LIKE '%a%') LIMIT 20 (line 308, D:\Workspace\myQuizz\trunk\server\protected\lib\prado-lib\Testing\Data\TDbCommand.php)
I don’t understand, why on the second request the ActiveRecord doesn’t include translations relation ?
Of course withtout “translations.text LIKE ‘%A%’” it works.
Thx for your help.
ML