Duplicate entry error when functino _swish_do_update called in cron

vj0914 - November 5, 2008 - 19:05
Project:Swish-E Indexer
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

there are two issues should be paid attention in future development.

<?php
function _swish_do_update() {
 
// Find all files available to the system
 
$file_result = db_query("SELECT * FROM {files}");

  while (
$file = db_fetch_array($file_result)) {
   
// Determine if full text information is already available
   
if (!db_result(db_query("SELECT `fulltext` from {swish_fulltext} WHERE filepath = '%s' AND nid = %d",$file['filepath'],$file['nid']))) {
.......
?>

I don't think files table has nid column, maybe you meant to use fid column?

<?php
.......
      if(
db_result(db_query("SELECT nid FROM {swish_fulltext} WHERE filepath = '%s' AND nid = %d", $file['filepath'], $file['nid']))) {
       
db_query("UPDATE {swish_fulltext} SET `fulltext` = '%s' WHERE `filepath` = '%s'",$text, $file['filepath']);
      } else {
       
db_query("INSERT INTO {swish_fulltext} (filepath,nid,`fulltext`) VALUES ('%s',%d,'%s')",$file['filepath'],$file['nid'],$text);
.......
?>

it always goes to INSERT even there is result.

 
 

Drupal is a registered trademark of Dries Buytaert.