當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TTransaction::rollback方法代碼示例

本文整理匯總了PHP中TTransaction::rollback方法的典型用法代碼示例。如果您正苦於以下問題:PHP TTransaction::rollback方法的具體用法?PHP TTransaction::rollback怎麽用?PHP TTransaction::rollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TTransaction的用法示例。


在下文中一共展示了TTransaction::rollback方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onSave

 public function onSave()
 {
     try {
         // open a transaction with database
         TTransaction::open($this->database);
         // get the form data
         $object = $this->form->getData($this->activeRecord);
         // validate data
         $this->form->validate();
         // stores the object
         $object->store();
         // fill the form with the active record data
         $this->form->setData($object);
         // close the transaction
         TTransaction::close();
         // shows the success message
         //new TMessage('info', AdiantiCoreTranslator::translate('Record saved'));
         parent::add(new TAlert('info', AdiantiCoreTranslator::translate('Record saved')));
         // reload the listing
         $this->onReload();
         return $object;
     } catch (Exception $e) {
         // get the form data
         $object = $this->form->getData($this->activeRecord);
         // fill the form with the active record data
         $this->form->setData($object);
         // shows the exception error message
         new TMessage('error', $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
開發者ID:edurbs,項目名稱:sobcontrole,代碼行數:32,代碼來源:TStandardFormListWAM.php

示例2: onView

 /**
  * method onEdit()
  * Executed whenever the user clicks at the edit button da datagrid
  */
 function onView($param)
 {
     try {
         if (isset($param['key'])) {
             // get the parameter $key
             $key = $param['key'];
             // open a transaction with database 'changeman'
             TTransaction::open('changeman');
             // instantiates object Document
             $object = new Document($key);
             $element = new TElement('div');
             $element->add($object->content);
             parent::add($element);
             // close the transaction
             TTransaction::close();
         } else {
             $this->form->clear();
         }
     } catch (Exception $e) {
         // shows the exception error message
         new TMessage('error', '<b>Error</b> ' . $e->getMessage());
         // undo all pending operations
         TTransaction::rollback();
     }
 }
開發者ID:jfrank1500,項目名稱:curso_php,代碼行數:29,代碼來源:ViewDocumentForm.class.php

示例3: onLogin

 /**
  * Autenticates the User
  */
 function onLogin()
 {
     try {
         TTransaction::open('permission');
         $data = $this->form->getData('StdClass');
         $this->form->validate();
         $user = SystemUser::autenticate($data->login, $data->password);
         if ($user) {
             $programs = $user->getPrograms();
             $programs['LoginForm'] = TRUE;
             TSession::setValue('logged', TRUE);
             TSession::setValue('login', $data->login);
             TSession::setValue('username', $user->name);
             TSession::setValue('frontpage', '');
             TSession::setValue('programs', $programs);
             $frontpage = $user->frontpage;
             if ($frontpage instanceof SystemProgram and $frontpage->controller) {
                 TApplication::gotoPage($frontpage->controller);
                 // reload
                 TSession::setValue('frontpage', $frontpage->controller);
             } else {
                 TApplication::gotoPage('EmptyPage');
                 // reload
                 TSession::setValue('frontpage', 'EmptyPage');
             }
         }
         TTransaction::close();
     } catch (Exception $e) {
         new TMessage('error', $e->getMessage());
         TSession::setValue('logged', FALSE);
         TTransaction::rollback();
     }
 }
開發者ID:cbsistem,項目名稱:templateERP_Bootstrap,代碼行數:36,代碼來源:LoginForm.class.php

示例4: onSave

 /**
  * Overloaded method onSave()
  * Executed whenever the user clicks at the save button
  */
 public function onSave()
 {
     // first, use the default onSave()
     $object = parent::onSave();
     // if the object has been saved
     if ($object instanceof Product) {
         $source_file = 'tmp/' . $object->photo_path;
         $target_file = 'images/' . $object->photo_path;
         $finfo = new finfo(FILEINFO_MIME_TYPE);
         // if the user uploaded a source file
         if (file_exists($source_file) and $finfo->file($source_file) == 'image/png') {
             // move to the target directory
             rename($source_file, $target_file);
             try {
                 TTransaction::open($this->database);
                 // update the photo_path
                 $object->photo_path = 'images/' . $object->photo_path;
                 $object->store();
                 TTransaction::close();
             } catch (Exception $e) {
                 new TMessage('error', '<b>Error</b> ' . $e->getMessage());
                 TTransaction::rollback();
             }
         }
     }
 }
開發者ID:jfrank1500,項目名稱:curso_php,代碼行數:30,代碼來源:ProductForm.class.php

示例5: onLogin

 /**
  * Validate the login
  */
 function onLogin()
 {
     try {
         TTransaction::open('changeman');
         $data = $this->form->getData('StdClass');
         // validate form data
         $this->form->validate();
         $auth = Member::authenticate($data->user, md5($data->password));
         if ($auth) {
             TSession::setValue('logged', TRUE);
             TSession::setValue('login', $data->user);
             TSession::setValue('language', $data->language);
             // reload page
             TApplication::gotoPage('NewIssueForm', 'nonono');
         }
         TTransaction::close();
         // finaliza a transação
     } catch (Exception $e) {
         TSession::setValue('logged', FALSE);
         // exibe a mensagem gerada pela exceção
         new TMessage('error', '<b>Erro</b> ' . $e->getMessage());
         // desfaz todas alterações no banco de dados
         TTransaction::rollback();
     }
 }
開發者ID:jfrank1500,項目名稱:curso_php,代碼行數:28,代碼來源:LoginForm.class.php

示例6: treat_success

 /** @param PDOStatement $query_result */
 private function treat_success($query_result)
 {
     if ($query_result->rowCount() > 0) {
         (new Insert_user_dummy(array('id_user' => $this->connected, 'id_dummy' => TTransaction::get_last_inserted_id())))->run();
     } else {
         TTransaction::rollback();
     }
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:9,代碼來源:Insert_dummy.class.php

示例7: treat_success

 /** @param PDOStatement $query_result */
 private function treat_success($query_result)
 {
     if ($query_result->rowCount() > 0) {
         (new Delete_invitation(array('id' => parent::get_input('id_invitation'))))->run();
     } else {
         TTransaction::rollback();
     }
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:9,代碼來源:Insert_user_user.class.php

示例8: treat_success

 /**
  * @param PDOStatement $query_result
  */
 private function treat_success($query_result)
 {
     if ($query_result->rowCount() > 1) {
         parent::set_error(1, "Mais de um item foi removido, assim, a remoção foi cancelada.");
         TTransaction::rollback();
     } elseif ($query_result->rowCount() == 0) {
         parent::set_error(1, "Nenhum item foi removido.");
     }
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:12,代碼來源:Delete_user.class.php

示例9: treat_success

 /** @param PDOStatement $query_result */
 private function treat_success($query_result)
 {
     if ($query_result->rowCount() > 0 && TSession::try_get_value('id_user', $id_user)) {
         (new Insert_user_event(array('id_user' => $id_user, 'id_event' => TTransaction::get_last_inserted_id())))->run();
     } else {
         parent::set_error(102);
         TTransaction::rollback();
     }
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:10,代碼來源:Insert_event.class.php

示例10: action

 public function action()
 {
     $attrs_cond = array('id');
     $sql = TTransaction::get_delete_query('event', $attrs_cond);
     // Parâmetros em ordem de aparição da query
     $query_values = parent::get_input_values($attrs_cond);
     // Resultado da query
     $query_result = TTransaction::safe_execute($sql, $query_values);
     if ($query_result === false) {
         parent::set_error(101);
         TTransaction::rollback();
     }
     return parent::get_result();
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:14,代碼來源:Delete_event.class.php

示例11: action

 public function action()
 {
     $attrs = array('id_user', 'id_dummy');
     $sql = TTransaction::get_insert_query('user_dummy', $attrs);
     // Parâmetros em ordem de aparição da query
     $query_values = parent::get_input_values($attrs);
     // Resultado da query
     $query_result = TTransaction::safe_execute($sql, $query_values);
     if ($query_result === false) {
         parent::set_error(101);
         TTransaction::rollback();
     }
     return parent::get_result();
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:14,代碼來源:Insert_user_dummy.class.php

示例12: action

 public function action()
 {
     $attrs = array('name', 'username', 'email', 'password');
     $attrs_cond = array('id');
     $sql = TTransaction::get_update_query('user', $attrs, $attrs_cond);
     // Parâmetros em ordem de aparição da query
     $query_values = parent::get_input_values(array_merge($attrs, $attrs_cond));
     $query_values[3] = sha1($query_values[3]);
     // Resultado da query
     $query_result = TTransaction::safe_execute($sql, $query_values);
     if ($query_result === false) {
         parent::set_error(101);
         TTransaction::rollback();
     }
     return parent::get_result();
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:16,代碼來源:Update_user.class.php

示例13: run

 public static function run()
 {
     self::$time_start = microtime(true);
     $log_msg = "";
     // TODO: Substituir por $_POST
     if (isset($_GET['class'])) {
         $class_name = $_GET['class'];
         if (class_exists($class_name)) {
             try {
                 /** @var SimpleAction $action */
                 $action = new $class_name();
                 $result = $action->run();
                 self::$result = array_merge(self::$result, $result);
                 TTransaction::close();
             } catch (PDOException $pdo_e) {
                 // Grava a excessão que ocorreu.
                 $log_msg = $pdo_e->getMessage();
                 switch ($pdo_e->errorInfo[1]) {
                     case 1062:
                     case 1452:
                         self::$result["error"] = $pdo_e->errorInfo[1];
                         break;
                     default:
                         self::$result["error"] = 101;
                 }
                 TTransaction::rollback();
             } catch (Exception $e) {
                 // Grava a excessão que ocorreu.
                 $log_msg = $e->getMessage();
                 self::$result["error"] = 1;
                 TTransaction::rollback();
             }
         } else {
             self::$result["error"] = 2;
         }
         if (self::$result["msg"] == null) {
             self::$result["msg"] = Tools::get_error_msg(self::$result["error"]);
         }
         $log_msg = $log_msg ? $log_msg : self::$result["msg"];
         if (isset(self::$result["error"]) && self::$result["error"] != 0) {
             TTransaction::log($log_msg, 'error');
         }
         self::addCurrentTime('Fim de chamada');
         self::$result['time'] = self::$times;
         echo json_encode(self::$result);
     }
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:47,代碼來源:TApplication.class.php

示例14: action

 public function action()
 {
     $attrs = array('id_event', 'id_transaction');
     $sql = TTransaction::get_insert_query('event_transaction', $attrs);
     // Parâmetros em ordem de aparição da query
     $query_values = parent::get_input_values($attrs);
     // Resultado da query
     $query_result = TTransaction::safe_execute($sql, $query_values);
     if ($query_result !== false) {
         // Sucesso!
         TTransaction::close();
     } else {
         parent::set_error(101);
         TTransaction::rollback();
     }
     return parent::get_result();
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:17,代碼來源:Insert_event_transaction.class.php

示例15: action

 public function action()
 {
     $attrs = array();
     $attrs_cond = array();
     $sql = TTransaction::get_update_query('table', $attrs, $attrs_cond);
     // Parâmetros em ordem de aparição da query
     $query_values = parent::get_input_values(array_merge($attrs, $attrs_cond));
     // Resultado da query
     $query_result = TTransaction::safe_execute($sql, $query_values);
     if ($query_result === false) {
         parent::set_error(101);
         TTransaction::rollback();
     } else {
         //$this->treat_success($query_result);
     }
     return parent::get_result();
 }
開發者ID:thalelinh,項目名稱:MoneyManager,代碼行數:17,代碼來源:base.class.php


注:本文中的TTransaction::rollback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。