public function replace($tableExpression, array $data, array $types = array())
    {
        $this->connect();

        if (empty($data)) {
            return $this->executeUpdate('REPLACE INTO ' . $tableExpression . ' ()' . ' VALUES ()');
        }

        return $this->executeUpdate(
            'REPLACE INTO ' . $tableExpression . ' (' . implode(', ', array_keys($data)) . ')' .
            ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')',
            array_values($data),
            is_string(key($types)) ? $this->extractTypeValues($data, $types) : $types
        );
    }
public function replace($tableExpression, array $data, array $types = array())
    {
        $this->connect();

        if (empty($data)) {
            return $this->executeUpdate('REPLACE INTO ' . $tableExpression . ' ()' . ' VALUES ()');
        }

        return $this->executeUpdate(
            'REPLACE INTO ' . $tableExpression . ' (' . implode(', ', array_keys($data)) . ')' .
            ' VALUES (' . implode(', ', array_fill(0, count($data), '?')) . ')',
            array_values($data),
            is_string(key($types)) ? $this->extractTypeValues($data, $types) : $types
        );
    }
public function replace ( $ tableExpression , array $ data , array $ types = array ( ) ) { $ this -> connect ( ) ; if ( empty ( $ data ) ) { return $ this -> executeUpdate ( 'REPLACE INTO ' . $ tableExpression . ' ()' . ' VALUES ()' ) ; } return $ this -> executeUpdate ( 'REPLACE INTO ' . $ tableExpression . ' (' . implode ( ', ' , array_keys ( $ data ) ) . ')' . ' VALUES (' . implode ( ', ' , array_fill ( 0 , count ( $ data ) , '?' ) ) . ')' , array_values ( $ data ) , is_string ( key ( $ types ) ) ? $ this -> extractTypeValues ( $ data , $ types ) : $ types ) ; }
Inserts a table row with specified data.
REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.

Table expression and columns are not escaped and are not safe for user-input.

@param string $tableExpression The expression of the table to insert data into, quoted or unquoted.
@param array  $data      An associative array containing column-value pairs.
@param array  $types     Types of the inserted data.

@return integer The number of affected rows.
Inserts a table row with specified data . REPLACE works exactly like INSERT except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index the old row is deleted before the new row is inserted .