1
I need to get the last row of a column using Cakephp.
I’m trying like this:
$idAtual = $this->Albun->find('all', array('fields' => 'codigo'));
Only he’s returning all the lines. How to get only the last?
1
I need to get the last row of a column using Cakephp.
I’m trying like this:
$idAtual = $this->Albun->find('all', array('fields' => 'codigo'));
Only he’s returning all the lines. How to get only the last?
2
You have to add descending order and change the all
for first
$idAtual = $this->Albun->find('first', array('fields' => 'codigo', 'order' => array('codigo DESC')));
More hints:
0
could do something like this
case inserted at the time
echo $this->Albun->getInsertID();
Insert the code here by taking the last inserted in the base for the table
echo $this->Albun->getLastInsertID();
Browser other questions tagged php cakephp
You are not signed in. Login or sign up in order to post.
Try to give a
order by desc
id and return only one line with thelimit
. This is a possibility there are other.– rray