Question

I want to display links of first and previous record. I use following code but it returns empty.

$neighbors = $this->names->find('neighbors', array('conditions'=>array('names.Id'=>12),'limit'=>1));

This is my working code below, which returns data for the current record

$this->set("names", $this->names->find('all',array('conditions'=>array('names.Id'=>$id))));

How can I achieve this. Please help me.

Thanks

Was it helpful?

Solution

As docs says http://book.cakephp.org/2.0/en/models/retrieving-your-data.html, you need to do like this

$neighbors = $this->names->find(
        'neighbors',
        array('field' => 'Id', 'value' => 12)
    );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top