MySQL/i's $db->query('some query') will return a result set for successful SELECT, SHOW, DESCRIBE or EXPLAIN, or return true for successful INSERT, UPDATE, DELETE, DROP, etc.
As such, we can easily identify the "type" of query:
$result = $db->query('some query that we want to identify');
if($result === false){
echo 'Error'; exit;
}
if($result === true){
// query is a successful INSERT, UPDATE, DELETE, DROP, etc.
}else{ // else type of $result will be result set
// query is a successful SELECT, SHOW, DESCRIBE, EXPLAIN
}
How can we do the above using PHP ADOdb?
I'm currently using:
$result = $db->Execute('some query');
if($result === false){
echo 'Error'; exit;
}
if(get_class($result) === 'ADORecordSet_empty'){
// query is a successful INSERT, UPDATE, DELETE, DROP, etc?
}else{
// query is a successful SELECT, SHOW, DESCRIBE, EXPLAIN ?
}
which seems to work, but it definitely feels fragile and "working against the API". Is there a better way to do it?
Are there built-in ADOdb functions to do it?