I am trying to find the rows of the current record within a group of records for display in a view.ctp. My controller named Uploads. I have id, Up_Time and value in my database table. I decided to search by Up_Time. Up_Time is a field that will display current import time.
Currently i'm using below code find by id, it fail to display the rows of current record. Is there something that can do with Up_Time to display the current record?
$this->set('Uploads', $this->Upload->find('list', array ('fields' =>
array('Upload.id'),'order' => array('Upload.id DESC');
Thanks in advance.
try to use all
instead of list
like this:
$this->set('Uploads', $this->Upload->find('all', array ('fields' =>
array('Upload.id'),'order' => array('Upload.id DESC')));
Method find list
is used when you have to get value from database and print result inside a select option
In your query now you can print only id
field pay attention, if you would like to print all row use this:
$this->set('Uploads', $this->Upload->find('all', array ('order' => array('Upload.id DESC')));
If you would like to take only the last try this:
$this->set('Uploads', $this->Upload->find('first', array ('order' => array('Upload.id DESC')));
UPDATE
If you would like to show last 5 records try this:
If you would like to take only the last try this using limit
conditions:
$this->set('Uploads', $this->Upload->find('all', array ('order' => array('Upload.id DESC'), 'limit' => 5));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments