CI_DB_query_builder::update PHP Method

update() public method

Compiles an update string and runs the query.
public update ( string $table = '', array $set = NULL, mixed $where = NULL, integer $limit = NULL ) : boolean
$table string
$set array An associative array of update values
$where mixed
$limit integer
return boolean TRUE on success, FALSE on failure
    public function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
    {
        // Combine any cached components with the current statements
        $this->_merge_cache();
        if ($set !== NULL) {
            $this->set($set);
        }
        if ($this->_validate_update($table) === FALSE) {
            return FALSE;
        }
        if ($where !== NULL) {
            $this->where($where);
        }
        if (!empty($limit)) {
            $this->limit($limit);
        }
        $sql = $this->_update($this->qb_from[0], $this->qb_set);
        $this->_reset_write();
        return $this->query($sql);
    }

Usage Example

Exemplo n.º 1
0
 public function update($id, array $data)
 {
     $data = $this->check_fields($data);
     if (array_key_exists('updated', $this->table_fields)) {
         $date['updated'] = date('Y-m-d H:i:s');
     }
     return $this->db->update($this->table, $data, ['id' => $id]);
 }
All Usage Examples Of CI_DB_query_builder::update