Temat: Problem z relacją hasMany i conditions.
witam,
w modelu mam m.in. cos takiego:
var $hasMany = array(
"ProductsDescription"=>array("className"=>"ProductsDescription",
"foreignKey"=>"products_id",
"conditions"=>null,
"fields"=>null)
);to mi generuje 2 zapytania:
SELECT `Product`.`id`, `Product`.`url`, `Product`.`symbol`, `Product`.`status`, `Product`.`images`, `Product`.`instrukcja` FROM `products` AS `Product` WHERE 1 = 1oraz
SELECT `ProductsDescription`.`id`, `ProductsDescription`.`products_id`, `ProductsDescription`.`products_name`, `ProductsDescription`.`products_description`, `ProductsDescription`.`products_url`, `ProductsDescription`.`products_lang` FROM `products_descriptions` AS `ProductsDescription` WHERE `ProductsDescription`.`products_id` IN (1, 2)co z kolei buduje ladna tablice
Array
(
[0] => Array
(
[Product] => Array
(
[id] => 1
[url]=> xxx
[symbol] => pp-01
[status] => 1
[images] =>
[instrukcja] =>
)
[ProductsDescription] => Array
(
[0] => Array
(
[id] => 1
[products_id] => 1
[products_name] => Pxxx
[products_description] =>
[products_url] => pxxxt
[products_lang] => de
)
[1] => Array
(
[id] => 2
[products_id] => 1
[products_name] => xxx
[products_description] =>
[products_url] => xxx
[products_lang] => en
)
[2] => Array
(
[id] => 3
[products_id] => 1
[products_name] => xxx
[products_description] =>
[products_url] => xxx
[products_lang] => pl
)
)
)
[1] => Array
(
[Product] => Array
(
[id] => 2
[url]=> xxx
[symbol] => pp-01
[status] => 1
[images] =>
[instrukcja] =>
)
[ProductsDescription] => Array
(
)
)
)Problem w tym ze nie chce na raz wyciagac wszystkich jezykow, tylko aktualnie wybrany jezyk zapisany w cookie.
probowalem tak
var $hasMany = array(
"ProductsDescription"=>array("className"=>"ProductsDescription",
"foreignKey"=>"products_id",
"conditions"=>array("ProductsDescription`.`products_lang"=>$ciasteczka),
"fields"=>null)
);ale wywala blad ze tam nie moze byc zmiennej.
dodatkowo czy tam gdzie jest generowana tablica to czy zamiast numerow moze byc pole z tabeli?
tzn zeby generowana tablica mogla wygladac tak
[0] => Array
(
[Product] => Array
(
[id] => 1
[url]=> xxx
[symbol] => pp-01
[status] => 1
[images] =>
[instrukcja] =>
)
[ProductsDescription] => Array
(
[de] => Array
(
[id] => 1
[products_id] => 1
[products_name] => Pxxx
[products_description] =>
[products_url] => pxxxt
[products_lang] => de
)
[en] => Array
(
[id] => 2
[products_id] => 1
[products_name] => xxx
[products_description] =>
[products_url] => xxx
[products_lang] => en
)
[pl] => Array
(
[id] => 3
[products_id] => 1
[products_name] => xxx
[products_description] =>
[products_url] => xxx
[products_lang] => pl
)
)
)
[1] => Array
(
[Product] => Array
(
[id] => 2
[url]=> xxx
[symbol] => pp-01
[status] => 1
[images] =>
[instrukcja] =>
)
[ProductsDescription] => Array
(
)
)
)Z gory dzieki za zainteresowanie.
pozdr.