tags:

views:

76

answers:

2
array(
    'Inmsg.user_id' => $this->Session->read('Auth.User.id'),
    "or" => array (
        "Inmsg.text LIKE" => "%".$search_term."%",
        "Contact.number LIKE" => "%".$search_term."%"
    )
)
A: 

Short of removing some of the criteria, this is the already the simplest notation for what you are trying to achieve.

neilcrookes
+1  A: 

Nitpicking:

array(
    'Inmsg.user_id' => $this->Auth->user('id'),
    "or" => array (
        "Inmsg.text LIKE"     => "%$search_term%",
        "Contact.number LIKE" => "%$search_term%"
    )
)

If what you want to search for is "text or number by logged in user contains $search_term", this is about as simple as you can get. You'll have to provide more context for possible further refinement.

deceze
yes thats what i want to do... what i didnt like about the query is that i repeat %search_term% twice and that i basically repeat the same thing twice on two different tables.
ondrobaco