Search code examples
testingrecordsetis-emptyadodb-php

how to check if ADOdb recordset is empty


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)){
    ...
    ...
    }