sorry for my english but I think that this probably can to be useful
for everybody, maybe this little update can to be committed but I
don't know how and where to make this...
I use Mysql and Cake 1.3.x
I has a problem to order some field using o normal paginate on views.
With simply queries its works perfectly but when we create 'virtual'
colums like, for example:
CONCAT(name,' ', surname) AS complete_name
Or using a sub query to calculate a column like:
( SELECT COUNT(*) FROM recipes WHERE recipes.some_field =
main_table.id) AS number_recipes
and so on, when we set a column name that not exist in the table
schema, the paginate method of controller class don't add this:
ORDER BY complete_name
For this i have added a little "else" on this file /cake/libs/
controller/controller.php line 1145.
The orginal code was:
f ($object->hasField($field)) {
$options['order'][$alias . '.' . $field] = $value;
} elseif ($object->hasField($field, true)) {
$options['order'][$field] = $value;
} elseif (isset($object->{$alias}) && $object->{$alias}-
>hasField($field)) {
$options['order'][$alias . '.' . $field] = $value;
}
The code modified is:
f ($object->hasField($field)) {
$options['order'][$alias . '.' . $field] = $value;
} elseif ($object->hasField($field, true)) {
$options['order'][$field] = $value;
} elseif (isset($object->{$alias}) && $object->{$alias}-
>hasField($field)) {
$options['order'][$alias . '.' . $field] = $value;
} else {
$options['order'][$field] = $value;
}
Maybe this change can create other kind of problem that I don't
consider for this I would like to have a expert opinion from the
community!
Massimo
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
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