Your telling it to find nothing.

You need to tell it what to find.

Like you had before

 $params => array('conditions' => array(
            'AND' => array(
                'OR' =>array(
                    'Post.name LIKE'      => '%' . $item . '%',
                   'Post.date LIKE'  => '%' . $item . '%',
                    'Post.poster LIKE' => '%' . $item . '%'),
            'NOT'=>array('Post.active'=> '0'))),
            'order' => 'Post.name',
             'recursive' => 1));  

$this->set('results', $this->Post->find('all' , $params));

It will find ALL Posts that meet these PARAMS and whatever you define in the
PARAMS

Dave

     
-----Original Message-----
From: Simon [mailto:[email protected]] 
Sent: September-24-09 11:09 AM
To: CakePHP
Subject: Re: Search and Find all


hi
thanks for you time i get  parse erorr when i  do this

$this->set('results', $this->find(...));

i tried it without the dots

$this->set('results', $this->find());

then i get
Call to undefined method PostsController::find()

thank you

On Sep 23, 5:45 pm, brian <[email protected]> wrote:
> You're testing for $item but your controller setting a variable $search.
>
> lthough, on 2nd look, you have a problem there, also. You're assigning 
> the result of your find() to $post but, further down, refer to $posts.
>
> Maybe you should simply do:
>
> $this->set('results', $this->find(...));
>
> view:
>
> if (empty($results)) { ...
>
>
>
> On Wed, Sep 23, 2009 at 6:32 PM, Simon <[email protected]> wrote:
>
> > whats the best way to show the user if there is no items found any 
> > code i can use  in my view
>
> > this i used but didnt work i got error
>
> > <?php
> > if (!$item) {
>
> > echo'<p> no items found  found</p>'; } ?>
>
> > this is in my post controller
>
> > function search($item = null) {
> >    $item = $this->params['url']['q'];
> >    $post = $this->Post->find('all',
> >        array('conditions' => array(
> >            'AND' => array(
> >                'OR' =>array(
> >                    'Post.name LIKE'      => '%' . $item . '%',
> >                    'Post.date LIKE'  => '%' . $item . '%',
> >                    'Post.poster LIKE' => '%' . $item . '%'),
> >            'NOT'=>array('Post.active'=> '0'))),
> >             'order' => 'Post.name',
> >             'recursive' => 1));
>
> >                if (!$item) {
> >                        $this->Session->setFlash(__('No Search Items 
> > Found', true));
> >                        $this->redirect(array('action'=>'index'));
> >                }
>
> >                $this->set('search', $posts);
> >        }- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
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