CodeIgniter Forums
Best way to update -> Table --> name + value field - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Best way to update -> Table --> name + value field (/showthread.php?tid=10038)



Best way to update -> Table --> name + value field - El Forum - 07-16-2008

[eluser]internut[/eluser]
Suggestions welcome. I'm not sure how to go about it just yet:

--
-- Table structure for table `settings`
--

Structure:

Code:
CREATE TABLE IF NOT EXISTS `settings` (
  `name` varchar(255) NOT NULL default '',
  `setting` mediumtext NOT NULL,
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Is there a way I can take an array and update fields in this "settings" table?

Or do i need to make a single query with a WHERE name='setting_name'

?


Best way to update -> Table --> name + value field - El Forum - 07-16-2008

[eluser]internut[/eluser]
I can do a line for each setting i want to update on a post. Which is:

Code:
$this->db->query("UPDATE settings SET setting='$_POST[admin_email]' WHERE name='admin_email'");

better way?