Jump to content

Recommended Posts

  • Moderators
Posted

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. :)

Guest lorathon
Posted

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);
       }

   }

  • Moderators
Posted

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);
}
   }

Guest lorathon
Posted

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;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...