We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

sql query: UPDATE

Development and Programming

@nnette's avatar
@nnette
109 posts
about 15 years ago
@nnette's avatar @nnette

I know that the ee sql query doesn’t allow this, but I can’t seem to get this to work even when I code it directly in php. Does ee not allow the use of UPDATE even when coded in php?

Thanks.

       
iain's avatar
iain
317 posts
about 15 years ago
iain's avatar iain

You’ll want to use the database class, if you’re working in your template make sure php is enabled.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 15 years ago
Lisa Wess's avatar Lisa Wess

Yes, UPDATE works if you use your own PHP. Iain gave you a great hint to get started.

If you still need help, please post your code. I’ll move this down to Dev & Programming for more community developer assistance as well.

Thank you!

       
Kernon's avatar
Kernon
173 posts
14 years ago
Kernon's avatar Kernon

Given below is a very rough example that only updates the value of the custom profile field 42 (not showing where the member ID nor other values come from):

global $DB;

$where_clause = "member_id = '" . $id_from_someplace . "'";
$data = array('m_field_id_42' => $myjunk);
$sql = $DB->update_string('exp_member_data', $data, $where_clause);
$DB->query($sql);
       
@nnette's avatar
@nnette
109 posts
14 years ago
@nnette's avatar @nnette

Thanks everyone. Got it.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.