/** * sends query to database - this is the protected one that must work * - internal functions use this rather than $this->query() * * @param string $string * @access protected * @return mixed none or PEAR_Error */ protected function _query($string) { $this->_connect(); $DB = DB_DataObject2::$CONNECTIONS[$this->_database_dsn_md5]; $options =& DB_DataObject2::$CONFIG; $_DB_driver = empty(DB_DataObject2::$CONFIG['db_driver']) ? 'PDO' : DB_DataObject2::$CONFIG['db_driver']; if (!empty(DB_DataObject2::$CONFIG['debug'])) { $this->debug($string, $log = "QUERY"); } if (strtoupper(trim($string)) == 'BEGIN') { $DB->beginTransaction(); return true; } if (strtoupper(trim($string)) == 'COMMIT') { $res = $DB->commit(); return $res; } if (strtoupper(trim($string)) == 'ROLLBACK') { $DB->rollBack(); return true; } if (!empty($options['debug_ignore_updates']) && strtolower(substr(trim($string), 0, 6)) != 'select' && strtolower(substr(trim($string), 0, 4)) != 'show' && strtolower(substr(trim($string), 0, 8)) != 'describe') { $this->debug('Disabling Update as you are in debug mode'); throw new Exception("Disabling Update as you are in debug mode", null); } //if (@DB_DataObject2::$CONFIG['debug'] > 1) { // this will only work when PEAR:DB supports it. //$this->debug($DB->getAll('explain ' .$string,DB_DATAOBJECT_FETCHMODE_ASSOC), $log="sql",2); //} // some sim $t = explode(' ', microtime()); DB_DataObject2::$QUERYENDTIME = $time = $t[0] + $t[1]; $result = $DB->query($string); if (!empty(DB_DataObject2::$CONFIG['debug'])) { $t = explode(' ', microtime()); DB_DataObject2::$QUERYENDTIME = $t[0] + $t[1]; $this->debug('QUERY DONE IN ' . ($t[0] + $t[1] - $time) . " seconds", 'query', 1); } if (is_array($result)) { $_DB_resultid = DB_DataObject2::$RESULTSEQ++; DB_DataObject2::$RESULTS[$_DB_resultid] = $result; $this->N = count(DB_DataObject2::$RESULTS[$_DB_resultid]); $this->_DB_resultid = $_DB_resultid; return; } elseif (is_int($result)) { return $result; } else { return false; } }