Only use "on duplicate key update" insert statement on MySQL connections.

(SQLite does not support this statement)
pull/5/head
wolfbeast 8 years ago
parent 1d840ef750
commit 06158570c5

@ -24,6 +24,7 @@
# Toby Elliott (telliott@mozilla.com) # Toby Elliott (telliott@mozilla.com)
# balu # balu
# Daniel Triendl <daniel@pew.cc> # Daniel Triendl <daniel@pew.cc>
# Moonchild <moonchild@palemoon.org>
# #
# Alternatively, the contents of this file may be used under the terms of # Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -220,12 +221,21 @@ class WeaveStorage
try try
{ {
$insert_stmt = 'insert into wbo (username, id, collection, parentid, predecessorid, sortindex, modified, payload, payload_size) if ( MYSQL_ENABLE )
values (:username, :id, :collection, :parentid, :predecessorid, :sortindex, :modified, :payload, :payload_size) {
on duplicate key update $insert_stmt = 'insert into wbo (username, id, collection, parentid, predecessorid, sortindex, modified, payload, payload_size)
username=values(username), id=values(id), collection=values(collection), parentid=values(parentid), values (:username, :id, :collection, :parentid, :predecessorid, :sortindex, :modified, :payload, :payload_size)
predecessorid=values(predecessorid), sortindex=values(sortindex), modified=values(modified), payload=values(payload), on duplicate key update
payload_size=values(payload_size)'; username=values(username), id=values(id), collection=values(collection), parentid=values(parentid),
predecessorid=values(predecessorid), sortindex=values(sortindex), modified=values(modified), payload=values(payload),
payload_size=values(payload_size)';
}
else
{
$insert_stmt = 'replace into wbo (username, id, collection, parentid, predecessorid, sortindex, modified, payload, payload_size)
values (:username, :id, :collection, :parentid, :predecessorid, :sortindex, :modified, :payload, :payload_size)';
}
$sth = $this->_dbh->prepare($insert_stmt); $sth = $this->_dbh->prepare($insert_stmt);
$username = $this->_username; $username = $this->_username;

Loading…
Cancel
Save