当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPWS_DB::rollback方法代码示例

本文整理汇总了PHP中PHPWS_DB::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::rollback方法的具体用法?PHP PHPWS_DB::rollback怎么用?PHP PHPWS_DB::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPWS_DB的用法示例。


在下文中一共展示了PHPWS_DB::rollback方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * Delete row from database that matches this object's $id.
  * Also, delete the associated document in filecabinet.
  */
 public function delete()
 {
     \PHPWS_Core::initModClass('filecabinet', 'Document.php');
     \PHPWS_DB::begin();
     $db = self::getDb();
     $db->addWhere('id', $this->id);
     $result = $db->delete();
     if (\PHPWS_Error::logIfError($result)) {
         \PHPWS_DB::rollback();
         return FALSE;
     }
     $doc = new \PHPWS_Document($this->document_fc_id);
     $result = $doc->delete();
     if (\PHPWS_Error::logIfError($result)) {
         \PHPWS_DB::rollback();
         return FALSE;
     }
     \PHPWS_DB::commit();
     return TRUE;
 }
开发者ID:jlbooker,项目名称:InternshipInventory,代码行数:24,代码来源:InternDocument.php

示例2: execute


//.........这里部分代码省略.........
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check supervisor's zip
     if (isset($_REQUEST['agency_sup_zip']) && $_REQUEST['agency_sup_zip'] != "" && !is_numeric($_REQUEST['agency_sup_zip'])) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=agency_sup_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The agency supervisor's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     // Sanity check course number
     if (isset($_REQUEST['course_no']) && $_REQUEST['course_no'] != '' && (strlen($_REQUEST['course_no']) > 20 || !is_numeric($_REQUEST['course_no']))) {
         $url = 'index.php?module=intern&action=ShowInternship&missing=course_no';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         \NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, "The course number provided is invalid. No changes were saved. Course numbers should be less than 20 digits (no letters, spaces, or punctuation).");
         \NQ::close();
         return \PHPWS_Core::reroute($url);
     }
     \PHPWS_DB::begin();
     /********************************
      * Load the existing internship *
      */
     try {
         $i = \Intern\InternshipFactory::getInternshipById($_REQUEST['internship_id']);
     } catch (\Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         \PHPWS_DB::rollback();
         throw $e;
     }
     // Load the student object
     try {
         $student = StudentProviderFactory::getProvider()->getStudent($i->getBannerId(), $i->getTerm());
     } catch (StudentNotFoundException $e) {
         $student = null;
         \NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "We couldn't find a matching student in Banner. Your changes were saved, but this student probably needs to contact the Registrar's Office to re-enroll.");
         \NQ::close();
     }
     $i->faculty_id = $_REQUEST['faculty_id'] > 0 ? $_REQUEST['faculty_id'] : null;
     $i->department_id = $_REQUEST['department'];
     $i->start_date = !empty($_REQUEST['start_date']) ? strtotime($_REQUEST['start_date']) : 0;
     $i->end_date = !empty($_REQUEST['end_date']) ? strtotime($_REQUEST['end_date']) : 0;
     $i->credits = $_REQUEST['credits'] != '' ? (int) $_REQUEST['credits'] : null;
     $avg_hours_week = (int) $_REQUEST['avg_hours_week'];
     $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null;
     $i->paid = $_REQUEST['payment'] == 'paid';
     $i->stipend = isset($_REQUEST['stipend']) && $i->paid;
     $i->pay_rate = $_REQUEST['pay_rate'];
     // Internship experience type
     if (isset($_REQUEST['experience_type'])) {
         $i->setExperienceType($_REQUEST['experience_type']);
     }
     if ($i->isInternational()) {
         // Set province
         $i->loc_province = $_POST['loc_province'];
     }
     // Address, city, zip are always set (no matter domestic or international)
     $i->loc_address = strip_tags($_POST['loc_address']);
     $i->loc_city = strip_tags($_POST['loc_city']);
     $i->loc_zip = strip_tags($_POST['loc_zip']);
开发者ID:jlbooker,项目名称:InternshipInventory,代码行数:67,代码来源:SaveInternship.php

示例3: execute


//.........这里部分代码省略.........
         return PHPWS_Core::reroute($url);
     }
     // Sanity check supervisor's zip
     if (isset($_REQUEST['agency_sup_zip']) && $_REQUEST['agency_sup_zip'] != "" && (strlen($_REQUEST['agency_sup_zip']) != 5 || !is_numeric($_REQUEST['agency_sup_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_sup_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency supervisor's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check course number
     if (isset($_REQUEST['course_no']) && $_REQUEST['course_no'] != '' && (strlen($_REQUEST['course_no']) > 20 || !is_numeric($_REQUEST['course_no']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=course_no';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The course number provided is invalid. No changes were saved. Course numbers should be less than 20 digits (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     PHPWS_DB::begin();
     // Create/Save agency
     $agency = new Agency();
     if (isset($_REQUEST['agency_id'])) {
         // User is editing internship
         try {
             $agency = new Agency($_REQUEST['agency_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     }
     $agency->name = $_REQUEST['agency_name'];
     $agency->address = $_REQUEST['agency_address'];
     $agency->city = $_REQUEST['agency_city'];
     $agency->zip = $_REQUEST['agency_zip'];
     $agency->phone = $_REQUEST['agency_phone'];
     if ($_REQUEST['location'] == 'internat') {
         /* Location is INTERNATIONAL. Country is required. Province was typed in. */
         $agency->state = $_REQUEST['agency_state'];
         $agency->province = $_REQUEST['agency_province'];
         $agency->country = $_REQUEST['agency_country'];
         $agency->supervisor_state = $_REQUEST['agency_sup_state'];
         $agency->supervisor_province = $_REQUEST['agency_sup_province'];
         $agency->supervisor_country = $_REQUEST['agency_sup_country'];
     } else {
         /* Location is DOMESTIC. Country is U.S. State was chosen from drop down */
         $agency->state = $_REQUEST['agency_state'] == -1 ? null : $_REQUEST['agency_state'];
         $agency->country = 'United States';
         $agency->supervisor_state = $_REQUEST['agency_sup_state'] == -1 ? null : $_REQUEST['agency_sup_state'];
         $agency->supervisor_country = 'United States';
     }
     $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name'];
     $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name'];
     $agency->supervisor_title = $_REQUEST['agency_sup_title'];
     $agency->supervisor_phone = $_REQUEST['agency_sup_phone'];
     $agency->supervisor_email = $_REQUEST['agency_sup_email'];
     $agency->supervisor_fax = $_REQUEST['agency_sup_fax'];
     $agency->supervisor_address = $_REQUEST['agency_sup_address'];
     $agency->supervisor_city = $_REQUEST['agency_sup_city'];
     $agency->supervisor_zip = $_REQUEST['agency_sup_zip'];
开发者ID:sinkdb,项目名称:InternshipInventory,代码行数:67,代码来源:SaveInternship.php

示例4: moveRow

 /**
  * Move row in a table based on a column designating the current order
  * direction == 1 means INCREASE order by one
  * direction == -1 means DECREASE order by one
  * @param string  order_column Table column that contains the order of the entries
  * @param string  id_column    Name of the id_column
  * @param integer id           Id of current row
  * @param integer direction    Direction to move the row
  */
 public function moveRow($order_column, $id_column, $id, $direction = 1)
 {
     if (!($direction == 1 || $direction == -1)) {
         if (strtolower($direction) == 'down') {
             $direction = 1;
         } elseif (strtolower($direction) == 'up') {
             $direction = -1;
         } else {
             return false;
         }
     }
     $total_rows = $this->count();
     if ($total_rows < 2) {
         return;
     }
     $db = clone $this;
     $db->reset();
     $db->addWhere($id_column, $id);
     $db->addColumn($order_column);
     $current_order = $db->select('one');
     if ($current_order == 1 && $direction == -1) {
         // moving up when current item is at top of list
         // need to shift all other items down and pop this on the end
         PHPWS_DB::begin();
         if (PHPWS_Error::logIfError($this->reduceColumn($order_column))) {
             PHPWS_DB::rollback();
             return false;
         }
         $db->reset();
         $db->addWhere($id_column, $id);
         $db->addValue($order_column, $total_rows);
         if (PHPWS_Error::logIfError($db->update())) {
             PHPWS_DB::rollback();
             return false;
         }
         PHPWS_DB::commit();
         unset($db);
         return true;
     } elseif ($current_order == $total_rows && $direction == 1) {
         // moving down when current item is at bottom/end of list
         // need to shift all other items up and shift this on the beginning
         PHPWS_DB::begin();
         if (PHPWS_Error::logIfError($this->incrementColumn($order_column))) {
             PHPWS_DB::rollback();
             return false;
         }
         $db->reset();
         $db->addWhere($id_column, $id);
         $db->addValue($order_column, 1);
         if (PHPWS_Error::logIfError($db->update())) {
             PHPWS_DB::rollback();
             return false;
         }
         PHPWS_DB::commit();
         unset($db);
         return true;
     } else {
         PHPWS_DB::begin();
         $db = clone $this;
         $db->addWhere($order_column, $current_order + $direction);
         $db->addValue($order_column, $current_order);
         if (PHPWS_Error::logIfError($db->update())) {
             PHPWS_DB::rollback();
             return false;
         }
         $db = clone $this;
         $db->addWhere($id_column, $id);
         $db->addValue($order_column, $current_order + $direction);
         if (PHPWS_Error::logIfError($db->update())) {
             PHPWS_DB::rollback();
             return false;
         }
         unset($db);
         return true;
     }
 }
开发者ID:jeffrafter,项目名称:InternshipInventory,代码行数:85,代码来源:SubselectDatabase.php

示例5: filecabinet_update


//.........这里部分代码省略.........
                    $content[] = '--- Created embedded column on multimedia table.';
                }
            }
            PHPWS_Core::initModClass('filecabinet', 'Multimedia.php');
            $result = $db->getObjects('PHPWS_Multimedia');
            if ($result) {
                foreach ($result as $mm) {
                    $mm->loadDimensions();
                    PHPWS_Error::logIfError($mm->save());
                }
            }
            $content[] = '--- Durations added to multimedia files.';
            fc_update_parent_links();
            if (!checkMultimediaDir($content, $home_dir)) {
                return false;
            }
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/2_0_0.txt');
            }
            $content[] = '</pre>';
        case version_compare($version, '2.0.1', '<'):
            $content[] = '<pre>2.0.1 changes
-------------
+ Updated youTube import.
+ Removed unused code.</pre>';
        case version_compare($version, '2.1.0', '<'):
            $content[] = '<pre>';
            $files = array('templates/image_view.tpl', 'templates/settings.tpl', 'javascript/pick_file/head.js', 'javascript/pick_file/scripts.js', 'javascript/update_file/head.js', 'templates/file_manager/placeholder.tpl', 'templates/document_edit.tpl', 'templates/image_edit.tpl', 'templates/multimedia_edit.tpl', 'templates/edit_folder.tpl', 'templates/embed_edit.tpl', 'templates/style.css', 'templates/file_manager/folder_content_view.tpl', 'templates/file_manager/resize.tpl');
            fc_updatefiles($files, $content);
            $db = new PHPWS_DB('folders');
            $db->begin();
            if (PHPWS_Error::logIfError($db->addTableColumn('max_image_dimension', 'smallint  not null default 0'))) {
                $content[] = '--- Unable to add max_image_dimension column to folders table.';
                $db->rollback();
                return false;
            } else {
                $content[] = '--- Added max_image_dimension column to folders table.';
            }
            $db = new PHPWS_DB('fc_file_assoc');
            if (PHPWS_Error::logIfError($db->addTableColumn('width', 'smallint NOT NULL default 0'))) {
                $content[] = '--- Unable to add width column to fc_file_assoc.';
                $db->rollback();
                return false;
            } else {
                $content[] = '--- Added width column to fc_file_assoc table';
            }
            if (PHPWS_Error::logIfError($db->addTableColumn('height', 'smallint NOT NULL default 0'))) {
                $content[] = '--- Unable to add height column to fc_file_assoc.';
                $db->rollback();
                return false;
            } else {
                $content[] = '--- Added height column to fc_file_assoc table';
            }
            if (PHPWS_Error::logIfError($db->addTableColumn('cropped', 'smallint NOT NULL default 0'))) {
                $content[] = '--- Unable to add cropped column to fc_file_assoc.';
                $db->rollback();
                return false;
            } else {
                $content[] = '--- Added cropped column to fc_file_assoc table';
            }
            $db->commit();
            if (!PHPWS_Boost::inBranch()) {
                $content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/filecabinet/boost/changes/2_1_0.txt');
            }
            $content[] = '</pre>';
        case version_compare($version, '2.2.0', '<'):
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:67,代码来源:update.php


注:本文中的PHPWS_DB::rollback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。