dbObject::update PHP Méthode

update() public méthode

public update ( array $data = null )
$data array Optional update data to apply to the object
    public function update($data = null)
    {
        if (empty($this->dbFields)) {
            return false;
        }
        if (empty($this->data[$this->primaryKey])) {
            return false;
        }
        if ($data) {
            foreach ($data as $k => $v) {
                $this->{$k} = $v;
            }
        }
        if (!empty($this->timestamps) && in_array("updatedAt", $this->timestamps)) {
            $this->updatedAt = date("Y-m-d H:i:s");
        }
        $sqlData = $this->prepareData();
        if (!$this->validate($sqlData)) {
            return false;
        }
        $this->db->where($this->primaryKey, $this->data[$this->primaryKey]);
        return $this->db->update($this->dbTable, $sqlData);
    }