shajis001
shajis001

Reputation: 3

How can i use Like in cake php

i want the alternative cakephp code for the above query

Select * from book where title like '%java%;

Upvotes: 0

Views: 99

Answers (2)

cowls
cowls

Reputation: 24334

OK, assuming you are using a find() query.

You can specify the conditions array as follows:

"conditions" => array("Book.title like" => "%java%")

or

"conditions" => array("Book.title like '%java%'")

I think both will work

Upvotes: 1

Giacomo Tüfekci
Giacomo Tüfekci

Reputation: 195

Docu complex find conditions

$this->Post->find('first', array (
    "Author.name" => "Bob", 
    "OR" => array (
        "Post.title LIKE" => "%magic%",
        "Post.created >" => date('Y-m-d', strtotime("-2 weeks"))
    )
));

Upvotes: 1

Related Questions