I'm having some problems with the DB::isError function identifying a non-object as an error object (or so it seems). I'm using postgreSQL 7.3.x. The relevant code is below:
/*******************[ my code start ]***********************/ $sql_queries = array(); $sql_queries[0] = 'BEGIN'; $sql_queries[1] = "INSERT INTO domain (name,table_name) VALUES('$domainname','$tablename')"; $sql_queries[2] = 'CREATE TABLE ' . $tablename . '_account () INHERITS (domain_account_template)'; $sql_queries[3] = 'CREATE TABLE ' . $tablename . '_alias () INHERITS (domain_alias_template)'; $sql_queries[4] = 'CREATE TABLE ' . $tablename . '_option () INHERITS (domain_account_template)'; $sql_queries[5] = 'END'; // go though and execute all the queries (it fails on the // first one foreach($sql_queries as $query) { // show me which query is executing echo $query . "<br/>"; $result = $db->query($query); // this tells me that $result is an integer == 1 and // so is DB_OK, which I believe the code above is returning echo getType($result) . ": " . $result . ": " . DB_OK . "<br/>"; //this test tells me that it is NOT an object if(is_object($result)) { echo "its an object."; } else {echo "its NOT an object"; } //this always ends up as true, because it executes the code //in this block if(DB::isError($result)); { //at this point, I get a fatal error saying that I'm //attempting to call a member function on a non-object $error = $result->getMessage() . $result->getDebugInfo(); $db->query('ABORT'); die($error); } } /********************[ my code end ]***********************/ now, when I looked at the DB::isError code, it looked like so: /** * Tell whether a result code from a DB method is an error * * @param int $value result code * * @return bool whether $value is an error * * @access public */ function isError($value) { return (is_object($value) && (get_class($value) == 'db_error' || is_subclass_of($value, 'db_error'))); } So, it seems, that although I've already found (in my code) that the variable in question is NOT an object, isError STILL finds that it is not only an object, but is an object of class db_error! I'm really confused. Clearly I'm missing something here. Does anyone have any pointers for me? -davidc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php