Thanks.
This post has been edited by tri: 25 January 2012 - 06:55 AM
Reason for edit: Topic description added
Posted 23 January 2012 - 10:51 PM
This post has been edited by tri: 25 January 2012 - 06:55 AM
Reason for edit: Topic description added
Posted 24 January 2012 - 12:40 AM
Posted 24 January 2012 - 01:10 AM
Posted 24 January 2012 - 01:32 AM
$criteria = new CDbCriteria(array('select'=>'name','order'=>'uploadId DESC'));
$lastRow = Upload::model()->find($criteria);
/* Generated SQL: SELECT name FROM upload ORDER BY uploadId DESC LIMIT 1 */
echo "The name of my most recent upload is: " . $lastRow->name;
Posted 24 January 2012 - 01:42 AM
Posted 24 January 2012 - 10:29 AM
/* Lets pretend this is my model */
public Upload
{
public function GetLastRow()
{
$criteria = new CDbCriteria(array('select'=>'name','order'=>'uploadId DESC'));
return($this->find($criteria));
}
}
/* Lets pretend this is my controller */
public UploadController
{
public function actionUpload()
{
$model = new Upload();
$lastRow = $model->GetLastRow();
}
}