After a good night's sleep, I did some more searching and found this:
http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
Don't think that it will help me too much, but it definitely explains
my
problem easier. I just want to sort with multiple tables.
On Jul 25, 9:45 pm, Dateve <[EMAIL PROTECTED]> wrote:
> I am using rdBloggery and adding on a few custom pieces to the system
> for a fun project to learn cakephp better.
>
> I have a list of users and they are sorting by whichever header I
> click on, but I ran into a problem causing me a little grief. I added
> a column from my Transaction model to the User list to show their
> latest transaction total. My new controller (TransactionsController)
> uses the standard pagination helper included with rdBloggery.
>
> My User model $hasMany looks like this:
> var $hasMany = array(
> 'Post' => array(
> 'className' =>'Post',
> 'foreignKey'=>'user_id',
> ),
> 'Photo' => array(
> 'className' =>'Photo',
> 'foreignKey'=>'user_id',
>
> ),
> 'Comment' => array(
> 'className' =>'Comment',
> 'foreignKey'=>'user_id',
>
> ),
> 'Transaction' => array(
> 'className' =>'Transaction',
> 'foreignKey'=>'user_id',
> 'limit' =>'1',
> 'order'
> =>'Transaction.created DESC',
> ),
> );
>
> and my Transaction model $belongsTo looks like this:
> var $belongsTo = array(
> 'User' =>
> array('className' => 'User',
> 'foreignKey' => 'user_id',
> ),
>
> );
>
> On the user list page I am trying to sort the list by a column created
> from the a single transaction record, when I try this:
>
> <th><?php echo $pagination-
>
> >sortLink('Funds',array('Transaction.total','desc'))?></th>
>
> I receive the following message:
>
> Query: SELECT `User`.`id`, `User`.`username`, `User`.`password`,
> `User`.`role`, `User`.`email`, `User`.`name`, `User`.`created`,
> `User`.`modified` FROM `users` AS `User` WHERE 1 = 1 ORDER BY
> `User`.`Transaction`.`total` ASC LIMIT 25
>
> This returns "SQL Error: 1054: Unknown column 'User.Transaction.total'
> in 'order clause'" I want it to know to use the transactions table (so
> FROM 'transactions' AS 'Transaction' would also be included in the sql
> query somehow?)
>
> Is it possible to sort by a column that is in a separate table? Is
> this possible?
> Would I need to provide you guys with any more information before this
> question could be answered?
>
> Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---