protected function updateRecord()
    {
        $sql = 'UPDATE '.$this->fq_name;
        $sets = '';
        $where = '1=1';
        $set_args = array();
        $where_args = array();
        $table_def = $this->getDefinition();
        foreach($this->instance as $column => $value) {
            if (in_array($column, $this->unique)) {
                $where .= ' AND '.$this->connection->identifierEscape($column).' = ?';
                $where_args[] = $value;
            } else {
                if (isset($this->columns[$column]['increment']) && $this->columns[$column]['increment']) {
                    continue;
                } else if (!isset($table_def[$column])) {
                    // underlying table is missing this column
                    continue;
                }
                $sets .= ' '.$this->connection->identifierEscape($column).' = ?,';
                $set_args[] = $value;
            }
        }
        $sets = substr($sets,0,strlen($sets)-1);

        $sql .= ' SET '.$sets.' WHERE '.$where;
        $all_args = $set_args;
        foreach ($where_args as $a) {
            $all_args[] = $a;
        }
        $prep = $this->connection->prepare($sql);
        $result = $this->connection->execute($prep, $all_args);

        if ($result) {
            $this->record_changed = false;
        }

        return $result ? true : false;
    }
protected function updateRecord()
    {
        $sql = 'UPDATE '.$this->fq_name;
        $sets = '';
        $where = '1=1';
        $set_args = array();
        $where_args = array();
        $table_def = $this->getDefinition();
        foreach($this->instance as $column => $value) {
            if (in_array($column, $this->unique)) {
                $where .= ' AND '.$this->connection->identifierEscape($column).' = ?';
                $where_args[] = $value;
            } else {
                if (isset($this->columns[$column]['increment']) && $this->columns[$column]['increment']) {
                    continue;
                } else if (!isset($table_def[$column])) {
                    // underlying table is missing this column
                    continue;
                }
                $sets .= ' '.$this->connection->identifierEscape($column).' = ?,';
                $set_args[] = $value;
            }
        }
        $sets = substr($sets,0,strlen($sets)-1);

        $sql .= ' SET '.$sets.' WHERE '.$where;
        $all_args = $set_args;
        foreach ($where_args as $a) {
            $all_args[] = $a;
        }
        $prep = $this->connection->prepare($sql);
        $result = $this->connection->execute($prep, $all_args);

        if ($result) {
            $this->record_changed = false;
        }

        return $result ? true : false;
    }
protected function updateRecord ( ) { $ sql = 'UPDATE ' . $ this -> fq_name ; $ sets = '' ; $ where = '1=1' ; $ set_args = array ( ) ; $ where_args = array ( ) ; $ table_def = $ this -> getDefinition ( ) ; foreach ( $ this -> instance as $ column => $ value ) { if ( in_array ( $ column , $ this -> unique ) ) { $ where .= ' AND ' . $ this -> connection -> identifierEscape ( $ column ) . ' = ?' ; $ where_args [ ] = $ value ; } else { if ( isset ( $ this -> columns [ $ column ] [ 'increment' ] ) && $ this -> columns [ $ column ] [ 'increment' ] ) { continue ; } else if ( ! isset ( $ table_def [ $ column ] ) ) { // underlying table is missing this column continue ; } $ sets .= ' ' . $ this -> connection -> identifierEscape ( $ column ) . ' = ?,' ; $ set_args [ ] = $ value ; } } $ sets = substr ( $ sets , 0 , strlen ( $ sets ) - 1 ) ; $ sql .= ' SET ' . $ sets . ' WHERE ' . $ where ; $ all_args = $ set_args ; foreach ( $ where_args as $ a ) { $ all_args [ ] = $ a ; } $ prep = $ this -> connection -> prepare ( $ sql ) ; $ result = $ this -> connection -> execute ( $ prep , $ all_args ) ; if ( $ result ) { $ this -> record_changed = false ; } return $ result ? true : false ; }
Helper. Build & execute update query
@return SQL result object or boolean false
Helper . Build & execute update query