summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
Diffstat (limited to 'system/database')
-rw-r--r--system/database/drivers/interbase/interbase_utility.php2
-rw-r--r--system/database/drivers/pdo/pdo_result.php19
-rw-r--r--system/database/drivers/postgre/postgre_driver.php95
3 files changed, 102 insertions, 14 deletions
diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
index 1b92af9b6..164211836 100644
--- a/system/database/drivers/interbase/interbase_utility.php
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -42,7 +42,7 @@ class CI_DB_interbase_utility extends CI_DB_utility {
* @param string $filename
* @return mixed
*/
- protected function backup($filename)
+ protected function _backup($filename)
{
if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
{
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index 19aee1dfc..0b8937cc5 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -84,19 +84,14 @@ class CI_DB_pdo_result extends CI_DB_result {
// Define the output
$output = array('assoc', 'object');
+ // Initial value
+ $this->result_assoc = array() and $this->result_object = array();
+
// Fetch the result
- foreach ($output as $type)
+ while ($row = $this->_fetch_assoc())
{
- // Define the method and handler
- $res_method = '_fetch_'.$type;
- $res_handler = 'result_'.$type;
-
- $this->$res_handler = array();
-
- while ($row = $this->$res_method())
- {
- $this->{$res_handler}[] = $row;
- }
+ $this->result_assoc[] = $row;
+ $this->result_object[] = (object) $row;
}
// Save this as buffer and marked the fetch flag
@@ -249,7 +244,7 @@ class CI_DB_pdo_result extends CI_DB_result {
*/
protected function _fetch_object()
{
- return $this->result_id->fetchObject();
+ return $this->result_id->fetch(PDO::FETCH_OBJ);
}
}
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 84bf768ee..17bd37b38 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -311,6 +311,27 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * "Smart" Escape String
+ *
+ * Escapes data based on type
+ * Sets boolean and null types
+ *
+ * @param string
+ * @return mixed
+ */
+ public function escape($str)
+ {
+ if (is_bool($str))
+ {
+ return ($str) ? 'TRUE' : 'FALSE';
+ }
+
+ return parent::escape($str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Affected Rows
*
* @return int
@@ -558,6 +579,78 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Where
+ *
+ * Called by where() or or_where()
+ *
+ * @param mixed
+ * @param mixed
+ * @param string
+ * @return object
+ *
+ */
+ protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
+ {
+ $type = $this->_group_get_type($type);
+
+ if ( ! is_array($key))
+ {
+ $key = array($key => $value);
+ }
+
+ // If the escape value was not set will will base it on the global setting
+ if ( ! is_bool($escape))
+ {
+ $escape = $this->_protect_identifiers;
+ }
+
+ foreach ($key as $k => $v)
+ {
+ $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
+
+ if (is_null($v) && ! $this->_has_operator($k))
+ {
+ // value appears not to have been set, assign the test to IS NULL
+ $k .= ' IS NULL';
+ }
+
+ if ( ! is_null($v))
+ {
+ if ($escape === TRUE)
+ {
+ $k = $this->protect_identifiers($k, FALSE, $escape);
+ $v = ' '.$this->escape($v);
+ }
+ elseif (is_bool($v))
+ {
+ $v = ($v ? ' TRUE' : ' FALSE');
+ }
+
+ if ( ! $this->_has_operator($k))
+ {
+ $k .= ' = ';
+ }
+ }
+ else
+ {
+ $k = $this->protect_identifiers($k, FALSE, $escape);
+ }
+
+ $this->qb_where[] = $prefix.$k.$v;
+ if ($this->qb_caching === TRUE)
+ {
+ $this->qb_cache_where[] = $prefix.$k.$v;
+ $this->qb_cache_exists[] = 'where';
+ }
+
+ }
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Close DB Connection
*
* @param resource
@@ -571,4 +664,4 @@ class CI_DB_postgre_driver extends CI_DB {
}
/* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file