diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-04-05 14:17:35 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-04-05 14:17:35 +0200 |
commit | 611a7ac596d5b37086a4f975a1b52664cdfb0de7 (patch) | |
tree | 8b5fcaf2e4b1b9796906c103df9da893501ede03 /system/database/DB_active_rec.php | |
parent | bf0ce689fae71a22abfaf1854c954f7a3b467d20 (diff) | |
parent | a3bca8f8c1e4cca5d763cbfe043999cbfd07cd21 (diff) |
Merge remote-tracking branch 'upstream/develop' into db-tests
Diffstat (limited to 'system/database/DB_active_rec.php')
-rw-r--r-- | system/database/DB_active_rec.php | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 34a88ce59..f5dcd3dd7 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -1223,10 +1223,10 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Generates a platform-specific insert string from the supplied data. * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ protected function _insert_batch($table, $keys, $values) { @@ -1362,10 +1362,10 @@ abstract class CI_DB_active_record extends CI_DB_driver { * * Generates a platform-specific insert string from the supplied data * - * @param string the table name - * @param array the insert keys - * @param array the insert values - * @return string + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string */ protected function _insert($table, $keys, $values) { @@ -1447,6 +1447,23 @@ abstract class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** + * Replace statement + * + * Generates a platform-specific replace string from the supplied data + * + * @param string the table name + * @param array the insert keys + * @param array the insert values + * @return string + */ + protected function _replace($table, $keys, $values) + { + return 'REPLACE INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; + } + + // -------------------------------------------------------------------- + + /** * Get UPDATE query string * * Compiles an update query and returns the sql @@ -1520,6 +1537,33 @@ abstract class CI_DB_active_record extends CI_DB_driver { // -------------------------------------------------------------------- /** + * Update statement + * + * Generates a platform-specific update string from the supplied data + * + * @param string the table name + * @param array the update data + * @param array the where clause + * @param array the orderby clause + * @param array the limit clause + * @return string + */ + protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE) + { + foreach ($values as $key => $val) + { + $valstr[] = $key.' = '.$val; + } + + return 'UPDATE '.$table.' SET '.implode(', ', $valstr) + .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '') + .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '') + .($limit ? ' LIMIT '.$limit : ''); + } + + // -------------------------------------------------------------------- + + /** * Validate Update * * This method is used by both update() and get_compiled_update() to |