The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
replace into .. values ... where???
apparently i can't use replace into blah blah with where, what's the alternative?
|
#2
|
|||
|
|||
Could you elaborate.
|
#3
|
||||
|
||||
i'm trying to do this [sql] $DB_site->query("
REPLACE INTO prs_users(favourites) VALUES(if(favourites='', $p, concat_ws(' ', favourites, $p))) WHERE userid = $bbuserinfo[userid] ");[/sql] but it gives me this error Code:
mysql error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE userid = 10' at line 3 mysql error number: 1064 |
#4
|
||||
|
||||
*bump*
|
#5
|
||||
|
||||
WHERE with REPLACE doesn't work.
REPLACE = INSERT, except that it does delete existing records with the same key first. So you can insert without having to check if the record does already exist. If you want to update a record (which you know does exist) you should use UPDATE. |
#6
|
||||
|
||||
problem is that i don't know if it exists or not that's why i made it a replace so that if it didn't exist it would it would create the record, can update do that?
i.e. [sql] $DB_site->query(" UPDATE prs_users(favourites) VALUES(if(favourites='', $p, concat_ws(' ', favourites, $p))) WHERE userid = $bbuserinfo[userid] ");[/sql] |
#7
|
||||
|
||||
No, UPDATE can just update existing records.
What's the Schema of prs_users? |
#8
|
||||
|
||||
Code:
| prs_user | ================================================= | recordid | userid | subscriptions | favourites | responseupdate | --------------------------------------------------------------- more info on the schema [sql]CREATE TABLE `prs_users` ( `recordid` int(10) unsigned NOT NULL auto_increment, `userid` int(10) NOT NULL default '0', `subscriptions` mediumtext collate latin1_general_ci NOT NULL, `favourites` mediumtext collate latin1_general_ci NOT NULL, `responseupdate` enum('1','0') collate latin1_general_ci NOT NULL default '1', PRIMARY KEY (`recordid`), KEY `userid` (`userid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;[/sql] |
#9
|
||||
|
||||
*bump*
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|