REPLACE cannot be used!
AlexisWilke - March 25, 2009 - 06:14
| Project: | Discuss This! |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hi there,
I have noticed that this module was making use of the REPLACE statement.
As you can see on this page: http://dev.mysql.com/doc/refman/5.0/en/replace.html (2nd paragraph after the syntax), REPLACE is a MySQL specific instruction. Quite handy, but not available for folks like me who are using a good, compliant SQL database: PostgreSQL. 8-)
I know it is annoying, but you need to issue a DELETE + INSERT INTO instead. The DELETE will do nothing if the entry does not already exist. The REPLACE does exactly that anyway. (make sure you replace all 3 instances)
Thank you.
Alexis
Sample:
<?php
/**
* Store a mapping between the given nid and a forum tid
**/
function _discussthis_set_forum($nid, $tid) {
$sql = 'DELETE FROM {discussthis_forums} WHERE nid = %d';
db_query($sql, $nid);
$sql = 'INSERT INTO {discussthis_forums} (nid, forum_tid) VALUES (%d, %d)';
db_query($sql, $nid, $tid);
}
?>
#1
Another thing, in this statement, you had double quotes for the strings. It needs to be single quotes.
<?php$sql = "SELECT n.nid, n.title FROM {node} n WHERE n.title like '%s' and n.type = 'forum'";
?>