1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58:
<?php
/**
* Database connection
*
* @category ICMS
* @package Database
*
* @copyright The ImpressCMS Project <http://www.impresscms.org>
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License (GPL)
* @version SVN: $Id$
*/
/**
* Database connection
*
* @category ICMS
* @package Database
*/
class icms_db_Connection extends PDO implements icms_db_IConnection {
/**
* Safely escape the string, but strips the outer quotes
*
* This is a legacy method and not part of PDO and must be declared in any class that implements this interface
*
* @see icms_db_IConnection::escape()
* @param string $string
* @return string
*/
public function escape($string) {
return substr($this->quote($string), 1, -1);
}
/**
* Executes an SQL statement and returns a result set as an SQL statement object
*
* @see PDO::query()
* @return
*/
public function query() {
$args = func_get_args();
$sql = $args[0];
// the use of icms_db_IConnection is correct - without it, the query count in debug is not correct
$result = call_user_func_array(array(parent::class, 'query'), $args);
// trigger events for the debug console - see plugins/preloads/debug_mode.php
if ($result) {
icms_Event::trigger('icms_db_IConnection', 'execute', $this, array('sql' => $args[0], 'errorno' => NULL, 'error' => NULL));
} else {
$errorinfo = $this->errorInfo();
icms_Event::trigger('icms_db_IConnection', 'execute', $this, array('sql' => $args[0], 'errorno' => $errorinfo[1], 'error' => $errorinfo[2]));
}
return $result;
}
}