commit f27d748246f112752bcc2795ace3759e40600b60
parent 508b35f6d1bc0cb2ae907f2de6b6adcef16083b1
Author: Dan Stillman <dstillman@zotero.org>
Date: Mon, 2 Oct 2006 01:29:09 +0000
Fix broken scraping and indexing
Diffstat:
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js
@@ -545,25 +545,26 @@ Scholar.Item.prototype.save = function(){
sql = "SELECT COUNT(*) FROM itemData WHERE itemID=? AND fieldID=?";
var countStatement = Scholar.DB.getStatement(sql);
- countStatement.bindInt32Parameter(0, this.getID());
sql = "UPDATE itemData SET value=? WHERE itemID=? AND fieldID=?";
var updateStatement = Scholar.DB.getStatement(sql);
- updateStatement.bindInt32Parameter(1, this.getID());
sql = "INSERT INTO itemData VALUES (?,?,?)";
var insertStatement = Scholar.DB.getStatement(sql);
- insertStatement.bindInt32Parameter(0, this.getID());
for (fieldID in this._changedItemData.items){
if (this.getField(fieldID)){
// Oh, for an INSERT...ON DUPLICATE KEY UPDATE
+ countStatement.bindInt32Parameter(0, this.getID());
countStatement.bindInt32Parameter(1, fieldID);
countStatement.executeStep();
var exists = countStatement.getInt64(0);
+ countStatement.reset();
// Update
if (exists){
+ updateStatement.bindInt32Parameter(1, this.getID());
+
Scholar.History.modify('itemData', 'itemID-fieldID',
[this.getID(), fieldID]);
@@ -587,7 +588,7 @@ Scholar.Item.prototype.save = function(){
this.getField(fieldID));
}
updateStatement.bindInt32Parameter(2, fieldID);
- updateStatement.executeStep();
+ updateStatement.execute();
}
}
@@ -596,6 +597,7 @@ Scholar.Item.prototype.save = function(){
Scholar.History.add('itemData', 'itemID-fieldID',
[this.getID(), fieldID]);
+ insertStatement.bindInt32Parameter(0, this.getID());
insertStatement.bindInt32Parameter(1, fieldID);
if (Scholar.ItemFields.getID('accessDate')==fieldID
@@ -617,7 +619,7 @@ Scholar.Item.prototype.save = function(){
this.getField(fieldID));
}
- insertStatement.executeStep();
+ insertStatement.execute();
}
}
}
@@ -714,13 +716,13 @@ Scholar.Item.prototype.save = function(){
// Use manual bound parameters to speed things up
var statement =
Scholar.DB.getStatement("INSERT INTO itemData VALUES (?,?,?)");
- statement.bindInt32Parameter(0, this.getID());
for (fieldID in this._changedItemData.items){
if (!this.getField(fieldID)){
continue;
}
+ statement.bindInt32Parameter(0, this.getID());
statement.bindInt32Parameter(1, fieldID);
if (Scholar.ItemFields.getID('accessDate')==fieldID
@@ -736,7 +738,7 @@ Scholar.Item.prototype.save = function(){
else {
statement.bindUTF8StringParameter(2, this.getField(fieldID));
}
- statement.executeStep();
+ statement.execute();
}
Scholar.History.add('itemData', 'itemID-fieldID',
diff --git a/chrome/chromeFiles/content/scholar/xpcom/fulltext.js b/chrome/chromeFiles/content/scholar/xpcom/fulltext.js
@@ -90,7 +90,6 @@ Scholar.Fulltext = new function(){
// Handle bound parameters manually for optimal speed
var statement1 = Scholar.DB.getStatement("INSERT INTO fulltextWords (word) VALUES (?)");
var statement2 = Scholar.DB.getStatement("INSERT OR IGNORE INTO fulltextItems VALUES (?,?)");
- statement2.bindInt32Parameter(1, itemID);
for each(var word in words){
if (existing['_' + word]){
@@ -98,12 +97,13 @@ Scholar.Fulltext = new function(){
}
else {
statement1.bindUTF8StringParameter(0, word);
- statement1.executeStep()
+ statement1.execute()
var wordID = Scholar.DB.getLastInsertID();
}
statement2.bindInt32Parameter(0, wordID);
- statement2.executeStep();
+ statement2.bindInt32Parameter(1, itemID);
+ statement2.execute();
}
statement1.reset();