public function update($table, array $data, $conditions)
    {
        $nameFields = array_keys($data);
        $preparedValues = $this->prepareValues($data);
        $queryString = "UPDATE {$table} SET ";

        $fNumber = 0;
        foreach ($preparedValues as $key => $value) {
            unset($value);
            $queryString .= "{$nameFields[$fNumber]} = {$key}, ";
            $fNumber++;
        }

        $queryString = preg_replace('/,\ $/', ' ', $queryString);
        $queryString .= "WHERE {$conditions};";

        $this->query($queryString, $preparedValues);

        return $this->getAffectedRows();
    }
public function update($table, array $data, $conditions)
    {
        $nameFields = array_keys($data);
        $preparedValues = $this->prepareValues($data);
        $queryString = "UPDATE {$table} SET ";

        $fNumber = 0;
        foreach ($preparedValues as $key => $value) {
            unset($value);
            $queryString .= "{$nameFields[$fNumber]} = {$key}, ";
            $fNumber++;
        }

        $queryString = preg_replace('/,\ $/', ' ', $queryString);
        $queryString .= "WHERE {$conditions};";

        $this->query($queryString, $preparedValues);

        return $this->getAffectedRows();
    }
public function update ( $ table , array $ data , $ conditions ) { $ nameFields = array_keys ( $ data ) ; $ preparedValues = $ this -> prepareValues ( $ data ) ; $ queryString = "UPDATE {$table} SET " ; $ fNumber = 0 ; foreach ( $ preparedValues as $ key => $ value ) { unset ( $ value ) ; $ queryString .= "{$nameFields[$fNumber]} = {$key}, " ; $ fNumber ++ ; } $ queryString = preg_replace ( '/,\ $/' , ' ' , $ queryString ) ; $ queryString .= "WHERE {$conditions};" ; $ this -> query ( $ queryString , $ preparedValues ) ; return $ this -> getAffectedRows ( ) ; }
Perform a UPDATE statement

@param string $table
@param array $data
@param string $conditions

@return int number of affected rows
Perform a UPDATE statement