Can you provide also the CategoryI18n and the UnitI18n models?
2008/4/21 senser <[EMAIL PROTECTED]>:
>
> any ideas ???
>
> On Apr 19, 10:33 am, senser <[EMAIL PROTECTED]> wrote:
> > Hello!
> >
> > I have fivemodels: Offers, Category, CategoryI18n, Unit & UnitI18n
> > and they're associated as follows:
> >
> > Offer--belongsTo-->Category
> > Offer--belongsTo-->Unit
> > Category--hasMany-->CategoryI18n
> > Unit--hasMany-->UnitI18n
> >
> > and here is the code frommodels:
> >
> > ### filemodels/offer.php ###
> > class Offer extends AppModel{
> >
> > var $name='Offer';
> > var $recursive=2;
> >
> > var $belongsTo=array('Unit'=>array('className'=>'Unit',
> >
> 'conditions'=>'',
> >
> 'order'=>'',
> >
> 'dependent'=>true,
> >
> 'foreignKey'=>'unit_id',
> >
> 'finderQuery'=>'',
> >
> 'fields'=>array(),
> >
> 'exclusive'=>false),
> >
> >
> 'Category'=>array('className'=>'Category',
> >
> 'conditions'=>'',
> >
> 'order'=>'',
> >
> 'dependent'=>true,
> >
> 'foreignKey'=>'category_id',
> >
> 'finderQuery'=>'',
> >
> 'fields'=>array(),
> >
> 'exclusive'=>false));
> >
> > }
> >
> > ########################
> >
> > ### filemodels/category.php ###
> > class Category extends AppModel{
> >
> > var $name='Category';
> > var $recursive=2;
> >
> > var
> $hasMany=array('CategoryI18n'=>array('className'=>'CategoryI18n',
> >
> 'conditions'=>'',
> >
> 'order'=>'CategoryI18n.locale DESC',
> >
> 'dependent'=>true,
> >
> 'foreignKey'=>'category_id',
> >
> 'finderQuery'=>'',
> >
> 'fields'=>array(),
> >
> 'exclusive'=>false));}
> >
> > ########################
> >
> > ### filemodels/unit.php ###
> > class Unit extends AppModel{
> >
> > var $name='Unit';
> > var $recursive=2;
> >
> > var $hasMany=array('UnitI18n'=>array('className'=>'UnitI18n',
> >
> 'conditions'=>'',
> >
> 'order'=>'UnitI18n.locale DESC',
> >
> 'dependent'=>true,
> >
> 'foreignKey'=>'unit_id',
> >
> 'finderQuery'=>'',
> >
> 'fields'=>array(),
> >
> 'exclusive'=>false));}
> >
> > ########################
> >
> > So when I try to fetch some offers recursively, I get the CategoryI18n
> > results, but not UnitI18n.
> > As you can see from the code, bothmodels(Category & Unit) arerelatedto
> Offer in same manner, and UnitI18n & CategoryI18n
> > respectively arerelatedto Unit & Category.
> >
> > $this->Offer->findAll(array(), array(), 'Offer.last_edit_date DESC',
> > 1, 1, 2); returns this:
> >
> > Array
> > (
> > [0] => Array
> > (
> > [Offer] => Array
> > (
> > [id] => 4
> > [category_id] => 2
> > [type_id] => 1
> > [status_id] => 2
> > [country_id] => 4
> > [region_id] =>
> > [settlement_id] =>
> > [district_id] =>
> > [qunatity] => 0
> > [unit_id] => 1
> > [currency_id] => 1
> > [price_per_unit] =>
> > [price_1] => 123
> > [price_2] => 234
> > [date] => 2008-04-18 13:51:48
> > [last_edit_date] => 2008-04-18 13:51:48
> > )
> >
> > [Unit] => Array
> > (
> > [id] => 1
> > )
> > [Category] => Array
> > (
> > [id] => 2
> > [category_id] => 1
> > [CategoryI18n] => Array
> > (
> > [0] => Array
> > (
> > [id] => 4
> > [category_id] => 2
> > [locale] => bul
> > [content] => 1-стайни
> > )
> >
> > [1] => Array
> > (
> > [id] => 3
> > [category_id] => 2
> > [locale] => eng
> > [content] => 1-room
> > )
> >
> > )
> >
> > )
> > )
> >
> > So Categories are fetched recursively but Units NOT.
> > And finally my biggest confusion is the fact that actually Cake runs
> > SQL queries for fetching UnitI18n as CategoryI18n but the result is
> > missing in the array
> >
> > Here is what controller produces as SQL statements:
> >
> > SELECT `Unit`.`id` FROM `units` AS `Unit` WHERE `Unit`.`id` = 1
> > SELECT `UnitI18n`.`id`, `UnitI18n`.`unit_id`, `UnitI18n`.`locale`,
> > `UnitI18n`.`content` FROM `unit_i18ns` AS `UnitI18n` WHERE
> > `UnitI18n`.`unit_id` IN (1) ORDER BY `UnitI18n`.`locale` DESC
> > SELECT `Category`.`id`, `Category`.`category_id` FROM `categories` AS
> > `Category` WHERE `Category`.`id` = 2
> > SELECT `CategoryI18n`.`id`, `CategoryI18n`.`category_id`,
> > `CategoryI18n`.`locale`, `CategoryI18n`.`content` FROM
> > `category_i18ns` AS `CategoryI18n` WHERE `CategoryI18n`.`category_id`
> > IN (2) ORDER BY `CategoryI18n`.`locale` DESC
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---