本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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.");
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}