Hi I want to use a simple search form, but I cant do it.can someone
help me?
My idea is use it with differents tables, models and parameters too.

I´m trying this code:

in controller:

function search($word = null){
    if($word !== null){
        $this->paginate = array(
            'YourModel' => array(
                'conditions' => $this->YourModel-
>searchConditions($word),
            ),
        );
        $this->set('result',$this->paginate());
    }
}

in Model:


function searchConditions($word){
    // your search for colmuns
    $searchFor = array(
        'colmun1',
        'colmun2',
        'colmun3',
    );

    $word = trim($word);
    $conditions = array('OR' => array());
    foreach($searchFor as $colmun){
        $conditions['OR']["$colmun like"] = "%$word%";
    }
    return $conditions;
}

And the view
<?
echo $form->create('Posts', array('action' => 'search'));

echo $form->input('query');

echo $form->end('Search Post');

?>

But its not working.

Thanks a lot. God bless you.

Alejus

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to