27 #require_once 'Zend/Db.php'; 32 #require_once 'Zend/Db/Select.php'; 179 #require_once 'Zend/Db/Adapter/Exception.php'; 191 $driverOptions = array();
196 if (array_key_exists(
'options',
$config)) {
202 if (array_key_exists(
'driver_options',
$config)) {
203 if (!empty(
$config[
'driver_options'])) {
205 foreach ((array)
$config[
'driver_options'] as $key =>
$value) {
206 $driverOptions[$key] =
$value;
211 if (!isset(
$config[
'charset'])) {
215 if (!isset(
$config[
'persistent'])) {
219 $this->_config = array_merge($this->_config,
$config);
220 $this->_config[
'options'] =
$options;
221 $this->_config[
'driver_options'] = $driverOptions;
231 $this->_caseFolding =
$case;
235 #require_once 'Zend/Db/Adapter/Exception.php'; 237 .
'Zend_Db::CASE_NATURAL, Zend_Db::CASE_LOWER, Zend_Db::CASE_UPPER');
244 if(defined($constant)) {
285 if (! array_key_exists(
'dbname',
$config)) {
287 #require_once 'Zend/Db/Adapter/Exception.php'; 288 throw new Zend_Db_Adapter_Exception(
"Configuration array must have a key for 'dbname' that names the database instance");
291 if (! array_key_exists(
'password',
$config)) {
295 #require_once 'Zend/Db/Adapter/Exception.php'; 299 if (! array_key_exists(
'username',
$config)) {
303 #require_once 'Zend/Db/Adapter/Exception.php'; 362 $profilerInstance =
null;
364 if ($profilerIsObject = is_object($profiler)) {
366 $profilerInstance = $profiler;
368 $profiler = $profiler->toArray();
373 #require_once 'Zend/Db/Profiler/Exception.php'; 375 .
' or Zend_Config when provided as an object');
379 if (is_array($profiler)) {
380 if (isset($profiler[
'enabled'])) {
381 $enabled = (bool) $profiler[
'enabled'];
383 if (isset($profiler[
'class'])) {
384 $profilerClass = $profiler[
'class'];
386 if (isset($profiler[
'instance'])) {
387 $profilerInstance = $profiler[
'instance'];
389 }
else if (!$profilerIsObject) {
390 $enabled = (bool) $profiler;
393 if ($profilerInstance ===
null) {
395 #require_once 'Zend/Loader.php'; 398 $profilerInstance =
new $profilerClass();
403 #require_once 'Zend/Db/Profiler/Exception.php'; 405 .
'Zend_Db_Profiler');
408 if (
null !== $enabled) {
409 $profilerInstance->setEnabled($enabled);
412 $this->_profiler = $profilerInstance;
445 $this->_defaultStmtClass =
$class;
457 public function query($sql, $bind = array())
465 $bind = $sql->getBind();
468 $sql = $sql->assemble();
474 if (!is_array($bind)) {
475 $bind = array($bind);
480 $stmt->execute($bind);
483 $stmt->setFetchMode($this->_fetchMode);
497 $this->_profiler->queryEnd($q);
511 $this->_profiler->queryEnd($q);
525 $this->_profiler->queryEnd($q);
543 foreach ($bind as $col => $val) {
546 $vals[] = $val->__toString();
554 $bind[
':col'.$i] = $val;
559 #require_once 'Zend/Db/Adapter/Exception.php'; 567 $sql =
"INSERT INTO " 569 .
' (' . implode(
', ', $cols) .
') ' 570 .
'VALUES (' . implode(
', ', $vals) .
')';
574 $bind = array_values($bind);
576 $stmt = $this->
query($sql, $bind);
598 foreach ($bind as $col => $val) {
600 $val = $val->__toString();
608 $bind[
':col'.$i] = $val;
613 #require_once 'Zend/Db/Adapter/Exception.php'; 628 .
' SET ' . implode(
', ', $set)
629 . (($where) ?
" WHERE $where" :
'');
635 $stmt = $this->
query($sql, array_values($bind));
637 $stmt = $this->
query($sql, $bind);
650 public function delete(
$table, $where =
'')
657 $sql =
"DELETE FROM " 659 . (($where) ?
" WHERE $where" :
'');
664 $stmt = $this->
query($sql);
681 if (!is_array($where)) {
682 $where = array($where);
684 foreach ($where as $cond => &$term) {
689 $term = $term->__toString();
696 $term =
'(' . $term .
')';
699 $where = implode(
' AND ', $where);
732 public function fetchAll($sql, $bind = array(), $fetchMode =
null)
734 if ($fetchMode ===
null) {
737 $stmt = $this->
query($sql, $bind);
738 $result = $stmt->fetchAll($fetchMode);
751 public function fetchRow($sql, $bind = array(), $fetchMode =
null)
753 if ($fetchMode ===
null) {
756 $stmt = $this->
query($sql, $bind);
757 $result = $stmt->fetch($fetchMode);
776 $stmt = $this->
query($sql, $bind);
779 $tmp = array_values(array_slice(
$row, 0, 1));
794 $stmt = $this->
query($sql, $bind);
811 $stmt = $this->
query($sql, $bind);
828 $stmt = $this->
query($sql, $bind);
829 $result = $stmt->fetchColumn(0);
844 return sprintf(
'%F',
$value);
846 return "'" . addcslashes(
$value,
"\000\n\r\\'\"\032") .
"'";
864 return '(' .
$value->assemble() .
')';
868 return $value->__toString();
872 foreach (
$value as &$val) {
875 return implode(
', ',
$value);
878 if (
$type !==
null && array_key_exists(
$type = strtoupper(
$type), $this->_numericDataTypes)) {
880 switch ($this->_numericDataTypes[
$type]) {
882 $quotedValue = (string) intval(
$value);
889 [+-]? # optional sign 891 0[Xx][\da-fA-F]+ # ODBC-style hexadecimal 892 |\d+ # decimal or octal, or MySQL ZEROFILL decimal 893 (?:[eE][+-]?\d+)? # optional exponent on decimals or octals 896 (
string)
$value, $matches)) {
897 $quotedValue = $matches[1];
901 $quotedValue = sprintf(
'%F',
$value);
1002 $quoted = $ident->__toString();
1004 $quoted =
'(' . $ident->assemble() .
')';
1006 if (is_string($ident)) {
1007 $ident = explode(
'.', $ident);
1009 if (is_array($ident)) {
1010 $segments = array();
1011 foreach ($ident as $segment) {
1013 $segments[] = $segment->__toString();
1021 $quoted = implode(
'.', $segments);
1041 if ($auto ===
false || $this->_autoQuoteIdentifiers ===
true) {
1043 return ($q . str_replace(
"$q",
"$q$q",
$value) . $q);
1098 switch ($this->_caseFolding) {
1100 $value = strtolower((
string) $key);
1103 $value = strtoupper((
string) $key);
1121 if ($this->_allowSerialization ==
false) {
1123 #require_once 'Zend/Db/Adapter/Exception.php'; 1125 get_class($this) .
' is not allowed to be serialized' 1128 $this->_connection =
null;
1131 array_diff_key(get_object_vars($this), array(
'_connection' =>
null))
1142 if ($this->_autoReconnectOnUnserialize ==
true) {
1192 abstract protected function _connect();
1214 abstract public function prepare($sql);
1240 abstract protected function _commit();
1245 abstract protected function _rollBack();
1264 abstract public function limit($sql,
$count, $offset = 0);
getQuoteIdentifierSymbol()
fetchOne($sql, $bind=array())
elseif(isset( $params[ 'redirect_parent']))
static loadClass($class, $dirs=null)
fetchCol($sql, $bind=array())
quote($value, $type=null)
const AUTO_RECONNECT_ON_UNSERIALIZE
fetchRow($sql, $bind=array(), $fetchMode=null)
lastInsertId($tableName=null, $primaryKey=null)
fetchAssoc($sql, $bind=array())
nextSequenceId($sequenceName)
lastSequenceId($sequenceName)
quoteTableAs($ident, $alias=null, $auto=false)
setStatementClass($class)
$_option $_optionId $class
update($table, array $bind, $where='')
quoteInto($text, $value, $type=null, $count=null)
_quoteIdentifierAs($ident, $alias=null, $auto=false, $as=' AS ')
fetchPairs($sql, $bind=array())
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
const AUTO_QUOTE_IDENTIFIERS
$_autoReconnectOnUnserialize
query($sql, $bind=array())
const ALLOW_SERIALIZATION
quoteColumnAs($ident, $alias, $auto=false)
fetchAll($sql, $bind=array(), $fetchMode=null)
describeTable($tableName, $schemaName=null)
insert($table, array $bind)
quoteIdentifier($ident, $auto=false)
_quoteIdentifier($value, $auto=false)
supportsParameters($type)
_checkRequiredOptions(array $config)
limit($sql, $count, $offset=0)