I need last test(table) id.
If I use (in SQL) 'SELECT MAX(id) FROM test
, then show the last id
.
But when I use that in my model, showing error.
Codes from model (Test_model):
function get_test_table_last_id() {
$test_table = $this->db->dbprefix('test');
$sql = "SELECT MAX($test_table.id) AS last_id FROM $test_table";
return $this->db->query($sql)->row()->last_id;
}
Codes from controller (Test controller):
$model_info = $this->Test_model->get_test_table_last_id()->last_id;
$view_data["last_id"] = $model_info;
$this->load->view("test_view/view", $view_data);
Codes from view (test_view):
<?php echo $last_id ?>
I'm getting this error: