diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-04-05 14:09:55 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-04-05 14:09:55 +0200 |
commit | 975034d50ed7b3c530631ba3e24a73e33be24eff (patch) | |
tree | 6118b48c33cf26f03ab761d046d8bc28b626fe40 /system/database/DB_active_rec.php | |
parent | 65d537ce35cc01c2f31144d695725255322cb792 (diff) |
Added a default _update() method to CI_DB_active_record
Diffstat (limited to 'system/database/DB_active_rec.php')
-rw-r--r-- | system/database/DB_active_rec.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 34a88ce59..22b57082e 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -1520,6 +1520,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 |