/** * updateUser * updates all non-null values supplied in the args in the database * * @param type $password * @param type $email * @param type $fname * @param type $lname * @param type $addr1 * @param type $addr2 * @param type $city * @param type $state * @param type $zip */ function updateUser($password, $email, $fname, $lname, $addr1, $addr2, $city, $state, $zip) { // call db function to update user try { UserDBAPI::updateUser($this->_uName, $password, $email, $fname, $lname, $addr1, $addr2, $city, $state, $zip); } catch (Exception $ex) { throw new Exception("Unabel to update user record : " . $ex . getMessage(), 0, $ex); } return true; }
result. The API use PostgreSQL as database, please modify the DB class if want to use other databases. Please check php.ini for necessary config. */ ini_set('display_errors', 1); date_default_timezone_set('UTC'); // Please change the timezone value // Please modify your db info accordingly $db_host = 'localhost'; $db_name = 'the_userdb_name'; $db_user = '******'; $db_pass = '******'; $db_table = 'the_table_name'; try { $API = new UserDBAPI($_REQUEST); echo $API->process(); } catch (Exception $e) { echo json_encode(array('status' => 'error', 'message' => $e->getMessage())); } class MethodNotAllowed extends Exception { } class UserDBAPI { protected $method = ''; protected $action = ''; protected $args = ''; protected $data = null; public function __construct($request, $db = null) {