dg / dibi

Dibi - smart database abstraction layer

Home Page:https://dibiphp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getRowCount with SQLSRV driver

pswmauro opened this issue · comments

Version: latest (4.2.7) on windows with PHP 8.1
Correctly installed Microsoft SQL Server driver for PHP. Connection inizialized with:
$db = new Dibi\Connection([ 'driver' => 'sqlsrv', 'host' => 'localhost', 'username' => 'user', 'password' => 'password', 'database' => 'TEST', 'charset' => 'UTF-8', ]);
I can successfully exec
$result = $db->query($qry)
and
$all = $result->fetchAll();
but if use
$result->getRowCount()
it throws exception "Row count is not available for unbuffered queries".

It is thrown by driver because the SQLServer API does not offer selected rows count function. You have to fetch all rows and count them manually.