phpdanger Posted September 3, 2015 Share Posted September 3, 2015 Super simple question for a total noob... I am trying to modify some code to write the number "1" to a fiedl in a MySQL database to force all members active.The active field is cuirrently all zero "0".Here is the snippet in question. public function createTable() { $table = new Am_Protect_Table($this, $this->getDb(), '?_users', 'id_user'); $table->setFieldsMapping(array( array(Am_Protect_Table::FIELD_NAME_F, 'full_name'), array(Am_Protect_Table::FIELD_LOGIN, 'user_name'), array(Am_Protect_Table::FIELD_PASS, 'password'), array(Am_Protect_Table::FIELD_EMAIL, 'email'), array("1", 'active'), )); return $table; } -------------------------------------------------------------------------- So my question is this:Is: array("1", 'active'), a valid statement for setting that field to 1? Spoiler: it doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/298047-writing-a-static-value-to-a-mysql-array/ Share on other sites More sharing options...
gizmola Posted September 3, 2015 Share Posted September 3, 2015 The very name of this method should indicate to you that it is not designed for updating values in a table. This is completely out of context, as obviously you are using some sort of database class or ORM here, but you've provided no information as to which one. To change the data in one or more rows of an existing table, I expect that there is one or more different methods for doing that. This also sounds like a one-off maintenance activity which begs the question, why not just go into mysql and issue: UPDATE ..._users SET 'active' = 1; Quote Link to comment https://forums.phpfreaks.com/topic/298047-writing-a-static-value-to-a-mysql-array/#findComment-1520211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.