本文整理汇总了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;
}
}
}