Moderators mark1million Posted September 6, 2011 Moderators Report Posted September 6, 2011 Hi Guys, I want to mod this bit of code to update another row in the database. /** * Accept the pilot (allow them into the system) */ public static function acceptPilot($pilotid) { return self::updateProfile($pilotid, array( 'confirmed' => PILOT_ACCEPTED, 'retired' => 0 )); } I want to update another rows info can i just add a sql query in to the loop like this? /** * Accept the pilot (allow them into the system) */ public static function acceptPilot($pilotid) { return self::updateProfile($pilotid, array( 'confirmed' => PILOT_ACCEPTED, 'retired' => 0 $query = "UPDATE ".TABLE_PREFIX."mytable SET retired = "1" WHERE pilotid='$pilotid'" )); } I have not even tested this yet just thought i would post what i wanted to do first see any comments. Quote
Guest lorathon Posted September 6, 2011 Report Posted September 6, 2011 I don't think that would not work. I would do it like this (NOT TESTED) But maybe you can get the idea /** * Accept the pilot (allow them into the system) */ public static function acceptPilot($pilotid) { $ret = self::updateProfile($pilotid, array( 'confirmed' => PILOT_ACCEPTED, 'retired' => 0 )); if($ret) { $query = "UPDATE ".TABLE_PREFIX."mytable SET retired = "1" WHERE pilotid='$pilotid'" DB::query($query); } } Quote
Moderators mark1million Posted September 7, 2011 Author Moderators Report Posted September 7, 2011 HI Jeff, Thanks for that but its not updating, I have changed to the following now but still no luck. If you have any more ideas public static function acceptPilot($pilotid) { return self::updateProfile($pilotid, array( 'confirmed' => PILOT_ACCEPTED, 'retired' => 0 )); if($ret) { $sql = "UPDATE `mydbname`.`mydbrow` SET `retired` = '0', WHERE `pilotid`='.$pilotid"; $res = DB::query($sql); } } Quote
Guest lorathon Posted September 7, 2011 Report Posted September 7, 2011 You can't use the "return self::" because what happens is that it will run the updateProfile function and then return the results. The next lines will not even be seen. I would check the query. Make sure that it is correct. You could remove the if statement and just let the query run if even the update fails (i havent had time to check to see if the updateProfile returns true or not.) You could add the following at the end to see if there is a problem with the query echo DB::$error; Quote
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.