public function update(DataAbstract $data)
    {
        if (!$data->isUpdated()) {
            return false;
        }

        //~ Reset binded fields
        $this->binds = array();

        foreach ($this->primaryKeys as $key) {
            $this->addWhere($key, $this->getDataValue($data, $key));
        }

        $set = $this->getQueryFieldsSet($data);
        if (empty($set)) {
            return false;
        }

        $where = $this->getQueryWhere();
        if (empty($where)) {
            throw new \LogicException(__METHOD__ . '|Where clause is empty!');
        }

        $query     = 'UPDATE ' . $this->getTable() . ' ' . $set . ' ' . $where;
        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        //~ Reset some data
        $data->resetUpdated();

        //~ Clear
        $this->clear();
        $this->deleteCache($data);

        return true;
    }
public function update(DataAbstract $data)
    {
        if (!$data->isUpdated()) {
            return false;
        }

        //~ Reset binded fields
        $this->binds = array();

        foreach ($this->primaryKeys as $key) {
            $this->addWhere($key, $this->getDataValue($data, $key));
        }

        $set = $this->getQueryFieldsSet($data);
        if (empty($set)) {
            return false;
        }

        $where = $this->getQueryWhere();
        if (empty($where)) {
            throw new \LogicException(__METHOD__ . '|Where clause is empty!');
        }

        $query     = 'UPDATE ' . $this->getTable() . ' ' . $set . ' ' . $where;
        $statement = $this->db->prepare($query);
        $statement->execute($this->binds);

        //~ Reset some data
        $data->resetUpdated();

        //~ Clear
        $this->clear();
        $this->deleteCache($data);

        return true;
    }
public function update ( DataAbstract $ data ) { if ( ! $ data -> isUpdated ( ) ) { return false ; } //~ Reset binded fields $ this -> binds = array ( ) ; foreach ( $ this -> primaryKeys as $ key ) { $ this -> addWhere ( $ key , $ this -> getDataValue ( $ data , $ key ) ) ; } $ set = $ this -> getQueryFieldsSet ( $ data ) ; if ( empty ( $ set ) ) { return false ; } $ where = $ this -> getQueryWhere ( ) ; if ( empty ( $ where ) ) { throw new \ LogicException ( __METHOD__ . '|Where clause is empty!' ) ; } $ query = 'UPDATE ' . $ this -> getTable ( ) . ' ' . $ set . ' ' . $ where ; $ statement = $ this -> db -> prepare ( $ query ) ; $ statement -> execute ( $ this -> binds ) ; //~ Reset some data $ data -> resetUpdated ( ) ; //~ Clear $ this -> clear ( ) ; $ this -> deleteCache ( $ data ) ; return true ; }
Update data into database

@param  $data
@return bool
@throws \LogicException
Update data into database