Esempio n. 1
0
 /**
  * Update user data if the user exists else insert data.
  *
  * @access public
  * @param  void
  * @return bool $response
  */
 public function save()
 {
     //Store response status
     $response = false;
     try {
         if (empty($this->_dbAdapter)) {
             $this->_dbAdapter = new Noobh_DB_Adapter();
         }
         $this->_dbAdapter->beginTransaction();
         //Log info
         Noobh_Log::info(__CLASS__ . '::' . __FUNCTION__ . '  -  Begin transaction for saving user information');
         if (!empty($this->_id)) {
             $this->_update();
         } else {
             $this->_insert();
         }
         $this->_dbAdapter->commit();
         $response = true;
     } catch (Exception $ex) {
         $this->_dbAdapter->rollBack();
         //Log exception
         Noobh_Log::fatal(__CLASS__ . '::' . __FUNCTION__ . '  -  User save failed with following error : [' . $ex->getCode() . ']' . $ex->getMessage());
         throw $ex;
     }
     return $response;
 }