CI_DB_active_record::update PHP Méthode

update() public méthode

Compiles an update string and runs the query
public update ( $table = '', $set = NULL, $where = NULL, $limit = NULL ) : object
Résultat object
    function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
    {
        // Combine any cached components with the current statements
        $this->_merge_cache();
        if (!is_null($set)) {
            $this->set($set);
        }
        if (count($this->ar_set) == 0) {
            if ($this->db_debug) {
                return $this->display_error('db_must_use_set');
            }
            return FALSE;
        }
        if ($table == '') {
            if (!isset($this->ar_from[0])) {
                if ($this->db_debug) {
                    return $this->display_error('db_must_set_table');
                }
                return FALSE;
            }
            $table = $this->ar_from[0];
        }
        if ($where != NULL) {
            $this->where($where);
        }
        if ($limit != NULL) {
            $this->limit($limit);
        }
        $sql = $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
        $this->_reset_write();
        return $this->query($sql);
    }

Usage Example

Exemple #1
0
 public function update()
 {
     $this->_set_row();
     $this->db->update($this->_forged_join());
     $this->_clear_forged_join();
     if ($this->_record_is_changed()) {
         return $this->db->affected_rows() > 0;
     }
     return true;
 }
All Usage Examples Of CI_DB_active_record::update