Friday, October 28, 2022

[FIXED] how to check if ADOdb recordset is empty

Issue

I ran into the problem while checking emptiness of the ADODB5 recordset

$db = ADONewConnection($dbdriver);
$db->Connect($dbhost, $dbuser, $dbpass, $dbname);
$rs = $db->Execute($query);

now, if I try to check recordset

if(isset($rs[0]))
...
...

I get the error Cannot use object of type ADORecordSet_mysqli as array

How do you check whether returned recordset is or isn't empty?


Solution

before isset evaluation I converted ADODB recordset to array

$ra = $rs->getRows();

then tested if $ra array is empty

if(empty($ra)){
...
...
}


Answered By - m1k3y3
Answer Checked By - Mary Flores (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.