summaryrefslogtreecommitdiffstats
path: root/system/database/DB_driver.php
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-24 22:14:38 +0200
committeradmin <devnull@localhost>2006-09-24 22:14:38 +0200
commitbb1d439a981023415569549d8b8c4987fa5b9b51 (patch)
tree098a08d4aa1fd20093e213f7e13ea4a8806ad0d6 /system/database/DB_driver.php
parent46563d570944d6c5af8b4f46ba1eeca111eabaa4 (diff)
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r--system/database/DB_driver.php82
1 files changed, 78 insertions, 4 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index ef37967dc..3f7c82627 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -190,11 +190,11 @@ class CI_DB_driver {
if ($this->db_debug)
{
- log_message('error', 'Query error: '.$this->error_message());
+ log_message('error', 'Query error: '.$this->_error_message());
return $this->display_error(
array(
- 'Error Number: '.$this->error_number(),
- $this->error_message(),
+ 'Error Number: '.$this->_error_number(),
+ $this->_error_message(),
$sql
)
);
@@ -481,7 +481,81 @@ class CI_DB_driver {
}
return $str;
- }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate an insert string
+ *
+ * @access public
+ * @param string the table upon which the query will be performed
+ * @param array an associative array data of key/values
+ * @return string
+ */
+ function insert_string($table, $data)
+ {
+ $fields = array();
+ $values = array();
+
+ foreach($data as $key => $val)
+ {
+ $fields[] = $key;
+ $values[] = $this->escape($val);
+ }
+
+ return $this->_insert($this->dbprefix.$table, $fields, $values);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Generate an update string
+ *
+ * @access public
+ * @param string the table upon which the query will be performed
+ * @param array an associative array data of key/values
+ * @param mixed the "where" statement
+ * @return string
+ */
+ function update_string($table, $data, $where)
+ {
+ if ($where == '')
+ return false;
+
+ $fields = array();
+ foreach($data as $key => $val)
+ {
+ $fields[$key] = $this->escape($val);
+ }
+
+ if ( ! is_array($where))
+ {
+ $dest = array($where);
+ }
+ else
+ {
+ $dest = array();
+ foreach ($where as $key => $val)
+ {
+ $prefix = (count($dest) == 0) ? '' : ' AND ';
+
+ if ($val != '')
+ {
+ if ( ! $this->_has_operator($key))
+ {
+ $key .= ' =';
+ }
+
+ $val = ' '.$this->escape($val);
+ }
+
+ $dest[] = $prefix.$key.$val;
+ }
+ }
+
+ return $this->_update($this->dbprefix.$table, $fields, $dest);
+ }
// --------------------------------------------------------------------