2013-06-13, 11:38 AM
I have created a custom field and I want to populate it for a certain bunch of users and if not everyone.
I am using update to update the records in this table but obviously its not going to exist for some users, as such I need to do an insert with on duplicate
I currently use the following code to update inside my plugin
I am going to struggle to turn that into an insert with duplicate key check.
The only other option I have is that on signup, I can put the record in place.
Any thoughts?[/align]
Ok I got the query to work with an insert and then on duplicate key which works fine, and will suit my purposes, is there any other thoughts on this though
I am using update to update the records in this table but obviously its not going to exist for some users, as such I need to do an insert with on duplicate
I currently use the following code to update inside my plugin
$sql = "UPDATE ".TABLE_PREFIX."userfields SET fid4 = CASE ufid ";
foreach ($updatecase as $id => $ordinal) {
$sql .= sprintf("WHEN %d THEN %d ", $id, $ordinal);
}
$sql .= "END";
I am going to struggle to turn that into an insert with duplicate key check.
The only other option I have is that on signup, I can put the record in place.
Any thoughts?[/align]
Ok I got the query to work with an insert and then on duplicate key which works fine, and will suit my purposes, is there any other thoughts on this though