PATCH: Use of nonstandard SQL prohibits Postgresql Usage

RonC - October 14, 2009 - 18:50
Project:Rotor Banner
Version:6.x-2.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

The use of "ON DUPLICATE KEY" which is a mysql-specific thing prohibits the use of this module with other databases.

This patch should work with pretty much every database:

Starting line 427, it should be:

<?php
function _rotor_save(&$node) {
  if (!
$node->nid) return;
 
$fid = 0;
  if (
is_object($node->rotor_image)) {
   
$fid = upload_element_save($node->rotor_image, 'rotor', FILE_EXISTS_RENAME);
  }
 
$exists = db_fetch_object(db_query("SELECT 1 FROM {rotor_item} WHERE nid = %d", $node->nid));
  if(
$exists)
   
db_query("UPDATE {rotor_item} SET fid=%d, alt_text='%s', image_title='%s', url='%s', link_target='%s' WHERE nid = %d",
    
$fid, $node->alt_text, $node->image_title, $node->url, $node->link_target, $node->nid);
  else
   
db_query(
     
"INSERT INTO {rotor_item} (nid, fid, alt_text, image_title, url, link_target)
      VALUES (%d, %d, '%s', '%s', '%s', '%s')"
     
,$node->nid, $fid, $node->alt_text, $node->image_title, $node->url, $node->link_target);
}
?>

#1

RonC - October 14, 2009 - 20:33
Status:patch (to be ported)» needs review

file is "rotor.module"

#2

mrfelton - November 5, 2009 - 10:27
Status:needs review» fixed

This is fixed in CVS now - thanks.

#3

System Message - November 19, 2009 - 10:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.