Bonjour,
Voila j'ai les modéles suivants:
class Currency extends AppModel {
var $name = 'Currency';
var $hasMany = array('Country');
}
class Country extends AppModel {
var $name = 'Country';
var $belongsTo = array('Currency');
var $hasMany = array('LangCountry');
}
class LangCountry extends AppModel {
public $name = 'LangCountry';
public $belongsTo = array('Country');
}
J'utilise un Country->find(); qui me renvoie le tableau suivant:
Mais en executant deux requetes sq, qui sont :
2007-08-13 17:32:17 CEST LOG: statement: SELECT "Country"."id" AS
"Country__id", "Country"."currency_id" AS "Country__currency_id",
"Country"."countries_iso_code_2" AS "Country__countries_iso_code_2",
"Country"."countries_iso_code_3" AS "Country__countries_iso_code_3",
"Country"."tel_regexp" AS "Country__tel_regexp", "Country"."zip_code"
AS "Country__zip_code", "Currency"."id" AS "Currency__id",
"Currency"."title" AS "Currency__title", "Currency"."code" AS
"Currency__code", "Currency"."symbol" AS "Currency__symbol" FROM
"countries" AS "Country" LEFT JOIN "currencies" AS "Currency" ON
("Country"."currency_id" = "Currency"."id") WHERE 1 = 1
2007-08-13 17:32:17 CEST LOG: statement: SELECT "LangCountry"."id" AS
"LangCountry__id", "LangCountry"."country_id" AS
"LangCountry__country_id", "LangCountry"."name" AS
"LangCountry__name", "LangCountry"."diminutive" AS
"LangCountry__diminutive" FROM "lang_countries" AS "LangCountry"
WHERE "LangCountry"."country_id" IN ('1')
Array ( [0] => Array ( [Country] => Array ( [id] => 1 [currency_id] =>
2 [countries_iso_code_2] => FRA [countries_iso_code_3] => FR
[tel_regexp] => [zip_code] => ) [Currency] => Array ( [id] => 2
[title] => Euro [code] => EURO [symbol] => EURO ) [LangCountry] => Array
( [0] => Array ( [id] => 4 [country_id] => 1 [name] => France
[diminutive] => fr ) [1] => Array ( [id] => 5 [country_id] => 1 [name]
=> francia [diminutive] => es ) ) ) )
Comme vous pouvez le voir pour l'association LangCountry il
me renvoie deux autres sous tableau. Ce que j'aimerai faire
c'est pouvoir mettre une condition de façons a ne récuperer
que les valeur de l'un des Tableau renvoyé dans l'association
LangCountry par exemple correspondant à 'diminutive' = fr.
J'ai tester cela:
Country->find(array('LangCountry.diminutive' =>'LIKE fr');
Mais cela ne passe car l'opération d'apres mes logs base de
données se fait en deux requetes sql. Donc je me retrouve
avec la 1ere requete qui ressemble a cela :
ELECT "Country"."id" AS "Country__id", "Country"."currency_id" AS
"Country__currency_id", "Country"."countries_iso_code_2" AS
"Country__countries_iso_code_2", "Country"."countries_iso_code_3" AS
"Country__countries_iso_code_3", "Country"."tel_regexp" AS
"Country__tel_regexp", "Country"."zip_code" AS "Country__zip_code",
"Currency"."id" AS "Currency__id", "Currency"."title" AS
"Currency__title", "Currency"."code" AS "Currency__code",
"Currency"."symbol" AS "Currency__symbol" FROM "countries" AS
"Country" LEFT JOIN "currencies" AS "Currency" ON
("Country"."currency_id" = "Currency"."id") WHERE
"LangCountry"."diminutive" Like 'fr'
Ce qui ne correponsd à rien du tout et me renvoie une erreur.
Merci pour votre aide
--~--~---------~--~----~------------~-------~--~----~
Groupe "Cakephp-fr".
Adresse : [email protected]
Pour résilier : [EMAIL PROTECTED]
Pour les options : http://groups.google.com/group/cakephp-fr?hl=fr
-~----------~----~----~----~------~----~------~--~---