Count belongsTo Source, Source hasMany Clients. I want to add
counterCache to Client model. So:
class Client extends HotelAppModel {
public $hasMany = array('Hotel.Reservation');
public $belongsTo = array('Hotel.Source' => array('counterCache' =>
true));
}
class Source extends HotelAppModel{
public $hasMany = array('Hotel.Client');
}
But its not working :/
I have wired sql errors ( smth is wrong with columns names )
Unknown column 'hotel.source_id' in 'field list'
Query: SELECT `hotel`.`source_id` FROM `clients` AS `Client` WHERE
`Client`.`id` = 8 LIMIT 1
Unknown column 'Client.hotel.source_id' in 'where clause'
Query: SELECT COUNT(*) AS `count` FROM `clients` AS `Client` WHERE
`Client`.`hotel`.`source_id` = 0
You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near '.`Source` SET `Hotel`.`Source`.`client_count` = 0 WHERE
`Hotel`.`Source`.`id` ' at line 1
Query: UPDATE `sources` AS `Hotel`.`Source` SET
`Hotel`.`Source`.`client_count` = 0 WHERE `Hotel`.`Source`.`id` = 0
Without counterCache in Client model everyting is ok.
http://pastie.org/523118
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment