src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
public function insert_id()
    {
        if (!$this->connection) {
            $this->last_error_id = "db_server_conn_error";
            return false;
        }
        
        if ($this->last_query_is_insert) {
            if (!$this->statement) {
                return null;
            }
            
            if (!sqlsrv_next_result($this->statement)) {
                $this->last_error = $this->sys_get_errors();
                $this->last_error_id = "db_query_error";
                
                trigger_error($this->last_error, E_USER_ERROR);
                return false;
            }
            
            $id = null;
            
            if (@sqlsrv_fetch($this->statement)) {
                $id = sqlsrv_get_field($this->statement, 0);
            }
            
            return $id;
        }
        
        $this->statement = @sqlsrv_query($this->connection, "SELECT SCOPE_IDENTITY() AS IID");
        if (!$this->statement) {
            $this->last_error = $this->sys_get_errors();
            $this->last_error_id = "db_query_error";
            
            trigger_error($this->last_error, E_USER_ERROR);
            return false;
        }
        
        if (!$this->fetch_row()) {
            $this->last_error_id = "db_query_error";
            return false;
        }
        
        $id = $this->field_by_name("IID");
        
        $this->free_result();
        
        return $id;
    }
public function insert_id()
    {
        if (!$this->connection) {
            $this->last_error_id = "db_server_conn_error";
            return false;
        }
        
        if ($this->last_query_is_insert) {
            if (!$this->statement) {
                return null;
            }
            
            if (!sqlsrv_next_result($this->statement)) {
                $this->last_error = $this->sys_get_errors();
                $this->last_error_id = "db_query_error";
                
                trigger_error($this->last_error, E_USER_ERROR);
                return false;
            }
            
            $id = null;
            
            if (@sqlsrv_fetch($this->statement)) {
                $id = sqlsrv_get_field($this->statement, 0);
            }
            
            return $id;
        }
        
        $this->statement = @sqlsrv_query($this->connection, "SELECT SCOPE_IDENTITY() AS IID");
        if (!$this->statement) {
            $this->last_error = $this->sys_get_errors();
            $this->last_error_id = "db_query_error";
            
            trigger_error($this->last_error, E_USER_ERROR);
            return false;
        }
        
        if (!$this->fetch_row()) {
            $this->last_error_id = "db_query_error";
            return false;
        }
        
        $id = $this->field_by_name("IID");
        
        $this->free_result();
        
        return $id;
    }
public function insert_id ( ) { if ( ! $ this -> connection ) { $ this -> last_error_id = "db_server_conn_error" ; return false ; } if ( $ this -> last_query_is_insert ) { if ( ! $ this -> statement ) { return null ; } if ( ! sqlsrv_next_result ( $ this -> statement ) ) { $ this -> last_error = $ this -> sys_get_errors ( ) ; $ this -> last_error_id = "db_query_error" ; trigger_error ( $ this -> last_error , E_USER_ERROR ) ; return false ; } $ id = null ; if ( @ sqlsrv_fetch ( $ this -> statement ) ) { $ id = sqlsrv_get_field ( $ this -> statement , 0 ) ; } return $ id ; } $ this -> statement = @ sqlsrv_query ( $ this -> connection , "SELECT SCOPE_IDENTITY() AS IID" ) ; if ( ! $ this -> statement ) { $ this -> last_error = $ this -> sys_get_errors ( ) ; $ this -> last_error_id = "db_query_error" ; trigger_error ( $ this -> last_error , E_USER_ERROR ) ; return false ; } if ( ! $ this -> fetch_row ( ) ) { $ this -> last_error_id = "db_query_error" ; return false ; } $ id = $ this -> field_by_name ( "IID" ) ; $ this -> free_result ( ) ; return $ id ; }
Returns the value of the auto increment field by the last insertion.

@return int|false
Returns the value of the auto increment field by the last insertion. In the case
of any error returns false.

@author Oleg Schildt
Returns the value of the auto increment field by the last insertion .