Whoa, that´s a lot of SQL! It might be easier to debug for people on
this group, and for yourself, if you made a smaller example, just to
see if you can get it to work in the simplest case.

No SQL errors then... I noticed this query:

SELECT `Transaction`.`id`, `Transaction`.`created`,
`Transaction`.`modified`, `Transaction`.`date`, `Transaction`.`name`,
`Transaction`.`amount`, `Transaction`.`user_id`,
`Transaction`.`account_id`, `Transaction`.`type_id`,
`Transaction`.`jointaccount_id` FROM `transactions` AS `Transaction`
WHERE `Transaction`.`user_id` = 1

So it looks like Cake is atempting to join the transactions view for
user=1.
If you run the above query manually, do you get any results?




On Apr 23, 6:10 pm, sumanpaul <[EMAIL PROTECTED]> wrote:
> Thx for concern ..here are the details.
>
> 1. User >hasMany >Balance(it's a view)
>
> 2. balance view sql : select `transactions`.`user_id` AS
> `user_id`,sum(`transactions`.`amount`) AS `total` from `transactions`
> group by `transactions`.`user_id`
>
> 3. Relations
>
> user.php
> ~~~~~~~~~~~~~~~~~~
>
> <?php
> class User extends AppModel {
>
>         var $name = 'User';
>
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>         var $belongsTo = array(
>                         'Group' => array('className' => 'Group',
>                                                                 'foreignKey' 
> => 'group_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 
> 'counterCache' => ''),
>         );
>
>         var $hasOne = array(
>                         'Balance' => array('className' => 'Balance',
>                                                                 'foreignKey' 
> => 'user_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 'dependent' 
> => ''),
>         );
>         var $hasMany = array(
>                         'Account' => array('className' => 'Account',
>                                                                 'foreignKey' 
> => 'user_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 'limit' => '',
>                                                                 'offset' => 
> '',
>                                                                 'dependent' 
> => '',
>                                                                 'exclusive' 
> => '',
>                                                                 'finderQuery' 
> => '',
>                                                                 
> 'counterQuery' => ''),
>                         'Transaction' => array('className' => 'Transaction',
>                                                                 'foreignKey' 
> => 'user_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => 
> 'date desc',
>                                                                 'limit' => 
> '10',
>                                                                 'offset' => 
> '',
>                                                                 'dependent' 
> => '',
>                                                                 'exclusive' 
> => '',
>                                                                 'finderQuery' 
> => '',
>                                                                 
> 'counterQuery' => ''),
>         );
>
>         var $hasAndBelongsToMany = array(
>                         'Jointaccount' => array('className' => 'Jointaccount',
>                                                 'joinTable' => 
> 'jointaccounts_users',
>                                                 'foreignKey' => 'user_id',
>                                                 'associationForeignKey' => 
> 'jointaccount_id',
>                                                 'conditions' => '',
>                                                 'fields' => '',
>                                                 'order' => '',
>                                                 'limit' => '',
>                                                 'offset' => '',
>                                                 'unique' => '',
>                                                 'finderQuery' => '',
>                                                 'deleteQuery' => '',
>                                                 'insertQuery' => ''),
>         );
>
> }
>
> ?>
>
> Balance.php
> ~~~~~~~~~~~~~~~~~~~~~~~~
>
> <?php
> class Balance extends AppModel {
>
>         var $name = 'Balance';
>
> }
>
> ?>
>
> transaction.php
> ~~~~~~~~~~~~~~~~~~~
>
> <?php
> class Transaction extends AppModel {
>
>         var $name = 'Transaction';
>
>         //The Associations below have been created with all possible keys,
> those that are not needed can be removed
>         var $belongsTo = array(
>                         'User' => array('className' => 'User',
>                                                                 'foreignKey' 
> => 'user_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 
> 'counterCache' => ''),
>                         'Account' => array('className' => 'Account',
>                                                                 'foreignKey' 
> => 'account_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 
> 'counterCache' => ''),
>                         'Type' => array('className' => 'Type',
>                                                                 'foreignKey' 
> => 'type_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 
> 'counterCache' => ''),
>                         'Jointaccount' => array('className' => 'Jointaccount',
>                                                                 'foreignKey' 
> => 'jointaccount_id',
>                                                                 'conditions' 
> => '',
>                                                                 'fields' => 
> '',
>                                                                 'order' => '',
>                                                                 
> 'counterCache' => ''),
>         );
>
> }
>
> ?>
> 4. sql executed : (recursion set 2, so it will have lot more queries)
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~~~~~~~~~~
> 60 queries took 18 ms Nr        Query   Error   Affected        Num. rows     
>   Took (ms)
> 1       DESC `users`            8       8       2
> 2       DESC `groups`           4       4       3
> 3       DESC `balances`         2       2       3
> 4       DESC `accounts`         6       6       2
> 5       DESC `transactions`             10      10      2
> 6       DESC `types`            4       4       2
> 7       DESC `jointaccounts`            4       4       2
> 8       SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active`, `Group`.`id`, `Group`.`name`,
> `Group`.`created`, `Group`.`modified`, `Balance`.`user_id`,
> `Balance`.`total` FROM `users` AS `User` LEFT JOIN `groups` AS `Group`
> ON (`User`.`group_id` = `Group`.`id`) LEFT JOIN `balances` AS
> `Balance` ON (`Balance`.`user_id` = `User`.`id` AND `User`.`id` = 1)
> WHERE `User`.`id` = 1 LIMIT 1           1       1       1
> 9       SELECT `Group`.`id`, `Group`.`name`, `Group`.`created`,
> `Group`.`modified` FROM `groups` AS `Group` WHERE `Group`.`id` = 1            
>   1
> 1       0
> 10      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`group_id` = 1           2       2       0
> 11      SELECT `Balance`.`user_id`, `Balance`.`total` FROM `balances` AS
> `Balance` WHERE `Balance`.`user_id` = 1                 1       1       1
> 12      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`user_id` = 1              2     
>   2       0
> 13      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 14      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 15      SELECT `Transaction`.`id`, `Transaction`.`created`,
> `Transaction`.`modified`, `Transaction`.`date`, `Transaction`.`name`,
> `Transaction`.`amount`, `Transaction`.`user_id`,
> `Transaction`.`account_id`, `Transaction`.`type_id`,
> `Transaction`.`jointaccount_id` FROM `transactions` AS `Transaction`
> WHERE `Transaction`.`account_id` = 1            28      28      0
> 16      SELECT `Transaction`.`id`, `Transaction`.`created`,
> `Transaction`.`modified`, `Transaction`.`date`, `Transaction`.`name`,
> `Transaction`.`amount`, `Transaction`.`user_id`,
> `Transaction`.`account_id`, `Transaction`.`type_id`,
> `Transaction`.`jointaccount_id` FROM `transactions` AS `Transaction`
> WHERE `Transaction`.`account_id` = 5            4       4       0
> 17      SELECT `Transaction`.`id`, `Transaction`.`created`,
> `Transaction`.`modified`, `Transaction`.`date`, `Transaction`.`name`,
> `Transaction`.`amount`, `Transaction`.`user_id`,
> `Transaction`.`account_id`, `Transaction`.`type_id`,
> `Transaction`.`jointaccount_id` FROM `transactions` AS `Transaction`
> WHERE `Transaction`.`user_id` = 1 ORDER BY date desc LIMIT 10           10    
>   10      0
> 18      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 19      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 20      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 21      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 22      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 23      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 24      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 25      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 26      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 27      SELECT `User`.`id`, `User`.`created`, `User`.`modified`,
> `User`.`username`, `User`.`password`, `User`.`name`,
> `User`.`group_id`, `User`.`active` FROM `users` AS `User` WHERE
> `User`.`id` = 1                 1       1       0
> 28      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 5           1       1     
>   0
> 29      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 1           1       1     
>   0
> 30      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 1           1       1     
>   0
> 31      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 1           1       1     
>   0
> 32      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 1           1       1     
>   0
> 33      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 1           1       1     
>   0
> 34      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 1           1       1     
>   0
> 35      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 5           1       1     
>   0
> 36      SELECT `Account`.`id`, `Account`.`created`, `Account`.`modified`,
> `Account`.`user_id`, `Account`.`name`, `Account`.`opening_balance`
> FROM `accounts` AS `Account` WHERE `Account`.`id` = 5           1       1     
>   0
> 37      SELECT `Account`.`id`, `Account`.`created`,
> ...
>
> read more »


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to