CodeIgniter Forums
HELP w/SQL Server 2012 and insert_id - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: HELP w/SQL Server 2012 and insert_id (/showthread.php?tid=70062)



HELP w/SQL Server 2012 and insert_id - chrismartinez99 - 02-14-2018

I have a piece of code:
PHP Code:
$this->db->insert($this->table$data);
$new_id        $this->db->insert_id(); 

For SQL Server 2012, the $new_id suddenly stopped working, the record is inserted, but I am not getting back the newly created ID.

2 questions:
1) Any ideas how to fix this?
2) How bad would it be to use:
Code:
$this->db->query('Select MAX(ID) from table')->row()
in this instance?

I am using the MSSQL db driver:
Code:
'dbdriver' => 'mssql',
'dbprefix' => 'frontend.',