Re: Order by Contain field

2009-10-24 Thread ark0n3

Yes I tried but CakePHP signaled wrong query.. In the end I managed to
move Person datas in the User table so that I removed a level of
relations and was able to order by User.surname.
I think it's a more reasonable DB model.

Thanks for your attention!

On 23 Ott, 19:11, jacmoe  wrote:
> Did you try with 'order' => array('Person.surname' => 'ASC') ?
> ((I'm away from any code, so I can't check atm))
>
> On Oct 23, 6:38 pm, ark0n3  wrote:
>
> > Yes, a related model but in the form
>
> > Teacher -> belongsTo User -> hasOne Person
>
> > so that I need to order by Person.surname,Person.name..
>
> > I tried 'order' => array('Person.surname ASC') but got no results..
>
> > On 23 Ott, 01:04, jacmoe  wrote:
>
> > > What do you mean?
> > > A totally unrelated model, or ?
>
> > >     var $paginate = array(
> > >     'fields' => array(all_fields_here),
> > >     'limit' => 15,
> > >     'order' => array(
> > >     'SomeModel.someField' => 'desc')
> > >     );
>
> > > Works with whatever your model $belongsTo.
>
> > > If that's not what you mean, explain some more. :)
>
> > > On Oct 22, 7:49 pm, ark0n3  wrote:
>
> > > > Hi Melanie
> > > > thanks for your kind reply.
> > > > I meant general sorting, not necessarily in the view, something like
> > > > SELECT * FROM User inner join Group order by Group.name
>
> > > > I think it's quite amazing such a basic feature could not be achieved
> > > > with CakePHP, a workaround has to exist (different from manually
> > > > sorting pagination results).
>
> > > > On 22 Ott, 16:33, Melanie Sommer 
> > > > wrote:
>
> > > > > > Hi
> > > > > > does anyone know if it's possible to order by a contained fields? It
> > > > > > seems to me like a simple task but I'm unable to manage it.. I have 
> > > > > > a
> > > > > > User model associated with a Group field and I'd like to order User 
> > > > > > by
> > > > > > Group.name.
>
> > > > > Do you mean paginator function sort() ? There you simpy need to type
> > > > > $paginator->sort('Group','Group.name');
>
> > > > > This only works if Group is directly related to your user, by
> > > > > belongsTo for example. I did not manage to get it work with any models
> > > > > that are not directly related with the current model and noone was
> > > > > able to answer me this question by now.
>
> > > > > Here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
> > > > > is written:
> > > > > "Cake 1.2 is still in development. I feel obligated to inform the
> > > > > reader of known weaknesses in pagination, before they dive in and
> > > > > start using it. There are only two things I know of which have been
> > > > > any hinderance to anybody.
> > > > > 1. Sorting by another model - Perhaps your model you want to paginate
> > > > > with has a belongsTo relationship to another model. You may want to
> > > > > sort by that other model. Currently this is not possible for security
> > > > > reasons. I'm told it will be done before Cake 1.2 becomes official.
> > > > > For now though, I am sorry you can only sort by the Model you are
> > > > > paginating with."
>
> > > > > So sorting by directly related models seems to be a rather new
> > > > > feature, so I fear it is generally not possible (without a lot of own
> > > > > code) to sort by models not directly related.
>
>
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order by Contain field

2009-10-23 Thread jacmoe

Did you try with 'order' => array('Person.surname' => 'ASC') ?
((I'm away from any code, so I can't check atm))

On Oct 23, 6:38 pm, ark0n3  wrote:
> Yes, a related model but in the form
>
> Teacher -> belongsTo User -> hasOne Person
>
> so that I need to order by Person.surname,Person.name..
>
> I tried 'order' => array('Person.surname ASC') but got no results..
>
> On 23 Ott, 01:04, jacmoe  wrote:
>
> > What do you mean?
> > A totally unrelated model, or ?
>
> >     var $paginate = array(
> >     'fields' => array(all_fields_here),
> >     'limit' => 15,
> >     'order' => array(
> >     'SomeModel.someField' => 'desc')
> >     );
>
> > Works with whatever your model $belongsTo.
>
> > If that's not what you mean, explain some more. :)
>
> > On Oct 22, 7:49 pm, ark0n3  wrote:
>
> > > Hi Melanie
> > > thanks for your kind reply.
> > > I meant general sorting, not necessarily in the view, something like
> > > SELECT * FROM User inner join Group order by Group.name
>
> > > I think it's quite amazing such a basic feature could not be achieved
> > > with CakePHP, a workaround has to exist (different from manually
> > > sorting pagination results).
>
> > > On 22 Ott, 16:33, Melanie Sommer 
> > > wrote:
>
> > > > > Hi
> > > > > does anyone know if it's possible to order by a contained fields? It
> > > > > seems to me like a simple task but I'm unable to manage it.. I have a
> > > > > User model associated with a Group field and I'd like to order User by
> > > > > Group.name.
>
> > > > Do you mean paginator function sort() ? There you simpy need to type
> > > > $paginator->sort('Group','Group.name');
>
> > > > This only works if Group is directly related to your user, by
> > > > belongsTo for example. I did not manage to get it work with any models
> > > > that are not directly related with the current model and noone was
> > > > able to answer me this question by now.
>
> > > > Here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
> > > > is written:
> > > > "Cake 1.2 is still in development. I feel obligated to inform the
> > > > reader of known weaknesses in pagination, before they dive in and
> > > > start using it. There are only two things I know of which have been
> > > > any hinderance to anybody.
> > > > 1. Sorting by another model - Perhaps your model you want to paginate
> > > > with has a belongsTo relationship to another model. You may want to
> > > > sort by that other model. Currently this is not possible for security
> > > > reasons. I'm told it will be done before Cake 1.2 becomes official.
> > > > For now though, I am sorry you can only sort by the Model you are
> > > > paginating with."
>
> > > > So sorting by directly related models seems to be a rather new
> > > > feature, so I fear it is generally not possible (without a lot of own
> > > > code) to sort by models not directly related.
>
>
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order by Contain field

2009-10-23 Thread ark0n3

Yes, a related model but in the form

Teacher -> belongsTo User -> hasOne Person

so that I need to order by Person.surname,Person.name..

I tried 'order' => array('Person.surname ASC') but got no results..

On 23 Ott, 01:04, jacmoe  wrote:
> What do you mean?
> A totally unrelated model, or ?
>
>     var $paginate = array(
>     'fields' => array(all_fields_here),
>     'limit' => 15,
>     'order' => array(
>     'SomeModel.someField' => 'desc')
>     );
>
> Works with whatever your model $belongsTo.
>
> If that's not what you mean, explain some more. :)
>
> On Oct 22, 7:49 pm, ark0n3  wrote:
>
> > Hi Melanie
> > thanks for your kind reply.
> > I meant general sorting, not necessarily in the view, something like
> > SELECT * FROM User inner join Group order by Group.name
>
> > I think it's quite amazing such a basic feature could not be achieved
> > with CakePHP, a workaround has to exist (different from manually
> > sorting pagination results).
>
> > On 22 Ott, 16:33, Melanie Sommer 
> > wrote:
>
> > > > Hi
> > > > does anyone know if it's possible to order by a contained fields? It
> > > > seems to me like a simple task but I'm unable to manage it.. I have a
> > > > User model associated with a Group field and I'd like to order User by
> > > > Group.name.
>
> > > Do you mean paginator function sort() ? There you simpy need to type
> > > $paginator->sort('Group','Group.name');
>
> > > This only works if Group is directly related to your user, by
> > > belongsTo for example. I did not manage to get it work with any models
> > > that are not directly related with the current model and noone was
> > > able to answer me this question by now.
>
> > > Here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
> > > is written:
> > > "Cake 1.2 is still in development. I feel obligated to inform the
> > > reader of known weaknesses in pagination, before they dive in and
> > > start using it. There are only two things I know of which have been
> > > any hinderance to anybody.
> > > 1. Sorting by another model - Perhaps your model you want to paginate
> > > with has a belongsTo relationship to another model. You may want to
> > > sort by that other model. Currently this is not possible for security
> > > reasons. I'm told it will be done before Cake 1.2 becomes official.
> > > For now though, I am sorry you can only sort by the Model you are
> > > paginating with."
>
> > > So sorting by directly related models seems to be a rather new
> > > feature, so I fear it is generally not possible (without a lot of own
> > > code) to sort by models not directly related.
>
>
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order by Contain field

2009-10-22 Thread jacmoe

What do you mean?
A totally unrelated model, or ?

var $paginate = array(
'fields' => array(all_fields_here),
'limit' => 15,
'order' => array(
'SomeModel.someField' => 'desc')
);

Works with whatever your model $belongsTo.

If that's not what you mean, explain some more. :)

On Oct 22, 7:49 pm, ark0n3  wrote:
> Hi Melanie
> thanks for your kind reply.
> I meant general sorting, not necessarily in the view, something like
> SELECT * FROM User inner join Group order by Group.name
>
> I think it's quite amazing such a basic feature could not be achieved
> with CakePHP, a workaround has to exist (different from manually
> sorting pagination results).
>
> On 22 Ott, 16:33, Melanie Sommer 
> wrote:
>
> > > Hi
> > > does anyone know if it's possible to order by a contained fields? It
> > > seems to me like a simple task but I'm unable to manage it.. I have a
> > > User model associated with a Group field and I'd like to order User by
> > > Group.name.
>
> > Do you mean paginator function sort() ? There you simpy need to type
> > $paginator->sort('Group','Group.name');
>
> > This only works if Group is directly related to your user, by
> > belongsTo for example. I did not manage to get it work with any models
> > that are not directly related with the current model and noone was
> > able to answer me this question by now.
>
> > Here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
> > is written:
> > "Cake 1.2 is still in development. I feel obligated to inform the
> > reader of known weaknesses in pagination, before they dive in and
> > start using it. There are only two things I know of which have been
> > any hinderance to anybody.
> > 1. Sorting by another model - Perhaps your model you want to paginate
> > with has a belongsTo relationship to another model. You may want to
> > sort by that other model. Currently this is not possible for security
> > reasons. I'm told it will be done before Cake 1.2 becomes official.
> > For now though, I am sorry you can only sort by the Model you are
> > paginating with."
>
> > So sorting by directly related models seems to be a rather new
> > feature, so I fear it is generally not possible (without a lot of own
> > code) to sort by models not directly related.
>
>
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order by Contain field

2009-10-22 Thread ark0n3

Hi Melanie
thanks for your kind reply.
I meant general sorting, not necessarily in the view, something like
SELECT * FROM User inner join Group order by Group.name

I think it's quite amazing such a basic feature could not be achieved
with CakePHP, a workaround has to exist (different from manually
sorting pagination results).



On 22 Ott, 16:33, Melanie Sommer 
wrote:
> > Hi
> > does anyone know if it's possible to order by a contained fields? It
> > seems to me like a simple task but I'm unable to manage it.. I have a
> > User model associated with a Group field and I'd like to order User by
> > Group.name.
>
> Do you mean paginator function sort() ? There you simpy need to type
> $paginator->sort('Group','Group.name');
>
> This only works if Group is directly related to your user, by
> belongsTo for example. I did not manage to get it work with any models
> that are not directly related with the current model and noone was
> able to answer me this question by now.
>
> Here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
> is written:
> "Cake 1.2 is still in development. I feel obligated to inform the
> reader of known weaknesses in pagination, before they dive in and
> start using it. There are only two things I know of which have been
> any hinderance to anybody.
> 1. Sorting by another model - Perhaps your model you want to paginate
> with has a belongsTo relationship to another model. You may want to
> sort by that other model. Currently this is not possible for security
> reasons. I'm told it will be done before Cake 1.2 becomes official.
> For now though, I am sorry you can only sort by the Model you are
> paginating with."
>
> So sorting by directly related models seems to be a rather new
> feature, so I fear it is generally not possible (without a lot of own
> code) to sort by models not directly related.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Order by Contain field

2009-10-22 Thread Melanie Sommer

> Hi
> does anyone know if it's possible to order by a contained fields? It
> seems to me like a simple task but I'm unable to manage it.. I have a
> User model associated with a Group field and I'd like to order User by
> Group.name.

Do you mean paginator function sort() ? There you simpy need to type
$paginator->sort('Group','Group.name');

This only works if Group is directly related to your user, by
belongsTo for example. I did not manage to get it work with any models
that are not directly related with the current model and noone was
able to answer me this question by now.

Here: http://bakery.cakephp.org/articles/view/advanced-pagination-1-2
is written:
"Cake 1.2 is still in development. I feel obligated to inform the
reader of known weaknesses in pagination, before they dive in and
start using it. There are only two things I know of which have been
any hinderance to anybody.
1. Sorting by another model - Perhaps your model you want to paginate
with has a belongsTo relationship to another model. You may want to
sort by that other model. Currently this is not possible for security
reasons. I'm told it will be done before Cake 1.2 becomes official.
For now though, I am sorry you can only sort by the Model you are
paginating with."

So sorting by directly related models seems to be a rather new
feature, so I fear it is generally not possible (without a lot of own
code) to sort by models not directly related.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Order by Contain field

2009-10-22 Thread ark0n3

Hi
does anyone know if it's possible to order by a contained fields? It
seems to me like a simple task but I'm unable to manage it.. I have a
User model associated with a Group field and I'd like to order User by
Group.name.

Thanks
Nicola
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---