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
        );
    }