Wednesday, September 17, 2008

Re: problem using find method in cakephp with conditions contains 'LIKE'

'conditions' => array('Book.title LIKE' => 'A%'),

The condition has been moved to the left hand side as a security
measure.

On Sep 17, 8:14 am, "jittos...." <jittopj...@gmail.com> wrote:
> i am a new comer in cakephp.. i am going through some tutorials in
> cakephp.. i found one problem i want to write find method for the
> following query
>
> SELECT `Book`.`isbn`, `Book`.`title`, `Book`.`author_name`
> FROM `books` AS `Book`
> WHERE `Book`.`title` LIKE 'A%'
> ORDER BY `Book`.`isbn` DESC
> LIMIT 2;
>
> i wrote
>
> find(
> 'all',
> array(
> 'conditions' => array('Book.title' => 'LIKE A%'),
> 'fields' => array(
> 'Book.isbn',
> 'Book.title',
> 'Book.author_name'
> ),
> 'order' => 'Book.isbn DESC',
> 'limit'=>2
> )
> );
>
> but it create a query like this..
>
> SELECT `Book`.`isbn`, `Book`.`title`, `Book`.`author_name`
> FROM `books` AS `Book`
> WHERE `Book`.`title` = 'LIKE A%
> ORDER BY `Book`.`isbn` DESC
> LIMIT 2;
>
> i.e, LIKE keyword is not working properly... did i do anything
> wrong?...
> plz help me if anybody have any idea about it...
> thanks,
> jittos....
--~--~---------~--~----~------------~-------~--~----~
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: