Get id of next and previous entry in cakephp

I want to display the links of the first and previous record. I use the 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.

thank

+4
source share
1 answer

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

$neighbors = $this->names->find(
        'neighbors',
        array('field' => 'Id', 'value' => 12)
    );
+4
source

Source: https://habr.com/ru/post/1538729/


All Articles