src/AbstractModel.php
public function update(array $data = array(), array $criteria = array())
    {
        $this->viewCheck(__FUNCTION__);

        $data = array_merge(
            array_filter($this->_schema['others'], array($this, 'filterRule')),
            $data);

        $params = array();
        $values = array_filter($this->_schema['values']);
        $others = array_filter($this->_schema['others']);
        foreach ($data as $key => $value)
            if (is_array($value))
                return false;
            elseif (isset($this->_properties['fields'][$key]))
                if (isset($values[$key]) && isset($others[$key])
                    && $values[$key]==$others[$key]
                )
                    continue;
                else
                    $params[':'.$key] = $value;

        if (empty($params))
            return true;

        $query = $this->buildUpdate($params, $criteria);

        if (!($query && $this->validate($params)))
            return false;

        $old = clone $this;
        if (!$this->beforeUpdate($params))
            return false;

        if ($result = $this->run($query, $params))
            $this->assign($params);

        if (!$this->afterUpdate($old))
            return false;

        return $result;
    }
public function update(array $data = array(), array $criteria = array())
    {
        $this->viewCheck(__FUNCTION__);

        $data = array_merge(
            array_filter($this->_schema['others'], array($this, 'filterRule')),
            $data);

        $params = array();
        $values = array_filter($this->_schema['values']);
        $others = array_filter($this->_schema['others']);
        foreach ($data as $key => $value)
            if (is_array($value))
                return false;
            elseif (isset($this->_properties['fields'][$key]))
                if (isset($values[$key]) && isset($others[$key])
                    && $values[$key]==$others[$key]
                )
                    continue;
                else
                    $params[':'.$key] = $value;

        if (empty($params))
            return true;

        $query = $this->buildUpdate($params, $criteria);

        if (!($query && $this->validate($params)))
            return false;

        $old = clone $this;
        if (!$this->beforeUpdate($params))
            return false;

        if ($result = $this->run($query, $params))
            $this->assign($params);

        if (!$this->afterUpdate($old))
            return false;

        return $result;
    }
public function update ( array $ data = array ( ) , array $ criteria = array ( ) ) { $ this -> viewCheck ( __FUNCTION__ ) ; $ data = array_merge ( array_filter ( $ this -> _schema [ 'others' ] , array ( $ this , 'filterRule' ) ) , $ data ) ; $ params = array ( ) ; $ values = array_filter ( $ this -> _schema [ 'values' ] ) ; $ others = array_filter ( $ this -> _schema [ 'others' ] ) ; foreach ( $ data as $ key => $ value ) if ( is_array ( $ value ) ) return false ; elseif ( isset ( $ this -> _properties [ 'fields' ] [ $ key ] ) ) if ( isset ( $ values [ $ key ] ) && isset ( $ others [ $ key ] ) && $ values [ $ key ] == $ others [ $ key ] ) continue ; else $ params [ ':' . $ key ] = $ value ; if ( empty ( $ params ) ) return true ; $ query = $ this -> buildUpdate ( $ params , $ criteria ) ; if ( ! ( $ query && $ this -> validate ( $ params ) ) ) return false ; $ old = clone $ this ; if ( ! $ this -> beforeUpdate ( $ params ) ) return false ; if ( $ result = $ this -> run ( $ query , $ params ) ) $ this -> assign ( $ params ) ; if ( ! $ this -> afterUpdate ( $ old ) ) return false ; return $ result ; }
Update, only when there is primary key
Update only when there is primary key