Monday, 30 July 2018

PHP MSSQL num_rows() not working with sqlsrv driver in Codeigniter

I'm getting the following error on a simple query that's supposed to return a number of rows:

Type: Error

Message: Call to a member function num_rows() on boolean

Filename: /var/www/cfc-dev/docroot/project/system/database/DB_query_builder.php

Line Number: 1428

I'm using Codeigniter 3.1.9. I recently started using PHP7.2 and also sqlsrv driver to connect to a MSSQL database.

In some other post, someone mentioned that scrollable should be set to an option different than SQLSRV_CURSOR_FORWARD so I dump the value of $this->scrollable in sqlsrv_driver.php and found out that its value is buffered

/**
     * Execute the query
     *
     * @param   string  $sql    an SQL query
     * @return  resource
     */
    protected function _execute($sql)
    {
        echo $this->scrollable; die();
        return ($this->scrollable === FALSE OR $this->is_write_type($sql))
            ? sqlsrv_query($this->conn_id, $sql)
            : sqlsrv_query($this->conn_id, $sql, NULL, array('Scrollable' => $this->scrollable));
    }

Not quite sure why it's failing. Any other queries that don't include num_rows() are fine so far. Thanks.



from PHP MSSQL num_rows() not working with sqlsrv driver in Codeigniter

No comments:

Post a Comment