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 is returning all lines. How to get only the last?
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 is returning all lines. How to get only the last?
You have to add descending order and change all
to first
$idAtual = $this->Albun->find('first', array('fields' => 'codigo', 'order' => array('codigo DESC')));
More infos:
could do something like this
currently inserted case
echo $this->Albun->getInsertID();
Insert the code here by putting the last one inserted in the base for the table
echo $this->Albun->getLastInsertID();