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


PHP PHPWS_DB::setLock方法代碼示例

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


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

示例1: saveUnregistered

 public function saveUnregistered()
 {
     /* @var $peep Signup_Peep Current signup person */
     $peep = $this->peep;
     /* @var $slot Signup_Slot Current slot peep is requesting */
     $slot = $this->slot;
     $db = new PHPWS_DB('signup_peeps');
     $db->addWhere('slot_id', $peep->slot_id);
     // lock carries over to saving of peep.
     $db->setLock('signup_peeps', 'read');
     /**
      * Check peeps table to count the number of registrations for the
      * requested slot
      * (addColumn has "count" indicated)
      */
     $db->addColumn('id', null, null, true);
     $db->addWhere('registered', 1);
     /**
      * @var $filled Number of registered peeps in the slot
      */
     $filled = $db->select('one');
     /**
      * See if the peep previous signed up for this sheet. If multiple is
      * allowed, previous is automatically false
      */
     if ($this->sheet->multiple) {
         $previous = false;
     } else {
         $db->reset();
         $db->addWhere('sheet_id', $peep->sheet_id);
         $db->addWhere('email', $peep->email);
         $db->addColumn('id');
         /* @var $previous integer */
         $previous = $db->select('one');
     }
     if (PHPWS_Error::logIfError($previous)) {
         $this->forwardMessage(dgettext('signup', 'An error occurred when trying to save your application.'), dgettext('signup', 'Sorry'));
         $this->sendMessage();
         return false;
     } elseif ($previous) {
         $this->forwardMessage(dgettext('signup', 'You cannot signup for more than one slot.'), dgettext('signup', 'Sorry'));
         $this->sendMessage();
         return false;
     }
     if ($slot->openings <= $filled) {
         $this->message = dgettext('signup', 'Sorry, the slot you chose is no longer available.');
         return false;
     }
     $peep->registered = 0;
     $peep->hashcheck = md5(rand());
     $peep->timeout = time() + SIGNUP_WINDOW;
     if (PHPWS_Error::logIfError($peep->save())) {
         $db->unlockTables();
         return false;
     } else {
         // success
         $db->unlockTables();
         if (PHPWS_Error::logIfError($this->emailRegistration())) {
             $peep->delete();
             $this->forwardMessage(dgettext('signup', 'There is a problem with our email server. Please try again later.'), dgettext('signup', 'Sorry'));
             $this->sendMessage();
             return false;
         } else {
             return true;
         }
     }
 }
開發者ID:HaldunA,項目名稱:phpwebsite,代碼行數:67,代碼來源:Signup.php


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