Customizing SMF > SMF Coding Discussion
add to database
The Wizard:
I want to add "dog8" to the users table shop_Dog. Can anyone tell me if this is correct or not?
Thanks
Wiz
--- Code: ---function onUse()
{
$dog = "UPDATE {db_prefix}members SET shop_Dog = dog8";
return 'You have Successfully added Cute Dog Number 8';
}
--- End code ---
Arantor:
That will update the shop_Dog column for every user in the table, assuming the column exists. I have no idea if that's right or not, because you haven't said what you're trying to do.
SA™:
you can use update memberdata function to do it per member
updateMemberData(memid, array('shopDog' => dog8));
if you want to do it for all members then
--- Code: ---$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET shop_Dog = dog8,
array());
--- End code ---
that assuming your on smf2 tho
Arantor:
I didn't get into the fact that *both* queries mentioned in this thread have syntax errors due to not putting dog8 in quotes or using the {string:var} encapsulation but I figured it was probably the wrong thing anyway since I don't see any reason why you'd update the value in every member's row.
SA™:
--- Code: ---$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET shop_Dog = {string:dog},
array(
'dog' => 'dog8',
));
--- End code ---
--- Quote ---updateMemberData(memid, array('shopDog' => 'dog8'));
--- End quote ---
my bad
Navigation
[0] Message Index
[#] Next page
Go to full version