summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-07-18 14:34:46 +0200
committerAndrey Andreev <narf@bofh.bg>2012-07-18 14:34:46 +0200
commitb04786599e1b032078f1d3bdd8941405d47447a0 (patch)
treece791020b36034fddbe81da58319140374c6b381 /system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
parentededc4a32a96315f18b7234153aa9cf7c87ca3ce (diff)
Remove dependancies on qb_like and remove unneeded parameters from _delete(), _like(), _update(), _update_batch()
Diffstat (limited to 'system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php')
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php67
1 files changed, 22 insertions, 45 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
index 9a476f143..d2afd1d71 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
@@ -164,27 +164,13 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
*
* @param string the table name
* @param array the update data
- * @param array the where clause
- * @param array the orderby clause (ignored)
- * @param array the limit clause (ignored)
- * @param array the like clause
* @return string
*/
- protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
+ protected function _update($table, $values)
{
- foreach ($values as $key => $val)
- {
- $valstr[] = $key.' = '.$val;
- }
-
- $where = empty($where) ? '' : ' WHERE '.implode(' ', $where);
-
- if ( ! empty($like))
- {
- $where .= ($where === '' ? ' WHERE ' : ' AND ').implode(' ', $like);
- }
-
- return 'UPDATE '.$table.' SET '.implode(', ', $valstr).$where;
+ $this->qb_limit = FALSE;
+ $this->qb_orderby = array();
+ return parent::_update($table, $values);
}
// --------------------------------------------------------------------
@@ -196,10 +182,10 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
*
* @param string the table name
* @param array the update data
- * @param array the where clause
+ * @param string the where key
* @return string
*/
- protected function _update_batch($table, $values, $index, $where = NULL)
+ protected function _update_batch($table, $values, $index)
{
$ids = array();
foreach ($values as $key => $val)
@@ -218,14 +204,14 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
$cases = '';
foreach ($final as $k => $v)
{
- $cases .= $k.' = (CASE '.$k."\n"
+ $cases .= $k.' = (CASE '.$index."\n"
.implode("\n", $v)."\n"
.'ELSE '.$k.' END), ';
}
- return 'UPDATE '.$table.' SET '.substr($cases, 0, -2)
- .' WHERE '.(($where !== '' && count($where) > 0) ? implode(' ', $where).' AND ' : '')
- .$index.' IN('.implode(',', $ids).')';
+ $this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);
+
+ return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_where();
}
// --------------------------------------------------------------------
@@ -236,19 +222,12 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
* Generates a platform-specific delete string from the supplied data
*
* @param string the table name
- * @param array the where clause
- * @param array the like clause
- * @param string the limit clause (ignored)
* @return string
*/
- protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table)
{
- $conditions = array();
-
- empty($where) OR $conditions[] = implode(' ', $where);
- empty($like) OR $conditions[] = implode(' ', $like);
-
- return 'DELETE FROM '.$table.(count($conditions) > 0 ? ' WHERE '.implode(' AND ', $conditions) : '');
+ $this->qb_limit = FALSE;
+ return parent::_delete($table);
}
// --------------------------------------------------------------------
@@ -273,11 +252,12 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
/**
* Where
*
- * Called by where() or or_where()
+ * Called by where(), or_where()
*
* @param mixed
* @param mixed
* @param string
+ * @param bool
* @return object
*/
protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
@@ -296,10 +276,6 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
? $this->_group_get_type('')
: $this->_group_get_type($type);
- $k = (($op = $this->_get_operator($k)) !== FALSE)
- ? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op)
- : $this->protect_identifiers($k, FALSE, $escape);
-
if (is_null($v) && ! $this->_has_operator($k))
{
// value appears not to have been set, assign the test to IS NULL
@@ -308,13 +284,13 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
if ( ! is_null($v))
{
- if ($escape === TRUE)
+ if (is_bool($v))
{
- $v = ' '.$this->escape($v);
+ $v = ' '.($v ? 'TRUE' : 'FALSE');
}
- elseif (is_bool($v))
+ elseif ($escape === TRUE)
{
- $v = ($v ? ' TRUE' : ' FALSE');
+ $v = ' '.(is_int($v) ? $v : $this->escape($v));
}
if ( ! $this->_has_operator($k))
@@ -323,10 +299,11 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
}
}
- $this->qb_where[] = $prefix.$k.$v;
+ $this->qb_where[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
if ($this->qb_caching === TRUE)
{
- $this->qb_cache_where[] = $prefix.$k.$v;
+ // check this shit
+ $this->qb_cache_where[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
$this->qb_cache_exists[] = 'where';
}