本文整理匯總了PHP中SmrMySqlDatabase::lock方法的典型用法代碼示例。如果您正苦於以下問題:PHP SmrMySqlDatabase::lock方法的具體用法?PHP SmrMySqlDatabase::lock怎麽用?PHP SmrMySqlDatabase::lock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SmrMySqlDatabase
的用法示例。
在下文中一共展示了SmrMySqlDatabase::lock方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: SmrMySqlDatabase
// *
// ***********************************
// debug the death
$debug = false;
// assume yes for now
$container["continue"] = "Yes";
// new db object to avoid interfearance with other db-objects
$dead_ppl = new SmrMySqlDatabase();
// we need to enter the loop at least once
$result = true;
// with a while loop we have to pick up only one result row from the db query
// do all our work (so over threads have the ability to pick up other rows)
// then lock table again to pic up another row
while ($result) {
// lock kills table for the whole process
$dead_ppl->lock("kills");
// pick one random row we are going to process
$dead_ppl->query("SELECT *\n\t\t\t\t\t FROM kills\n\t\t\t\t\t WHERE game_id = {$player->game_id} AND\n\t\t\t\t\t processed = 'FALSE'\n\t\t\t\t\t ORDER BY rand()\n\t\t\t\t\t LIMIT 1\n\t\t\t\t\t ");
// did we get one result?
if ($dead_ppl->next_record()) {
// get their id's
$killed_id = $dead_ppl->f("dead_id");
$killer_id = $dead_ppl->f("killer_id");
$curr_sector = $dead_ppl->f("sector_id");
$dead_exp = $dead_ppl->f("dead_exp");
$kill_exp = $dead_ppl->f("kill_exp");
// we have to set the 'process' column to true here
// BEFORE we give access free to that table.
// otherwise another thread could pick this row up
// but we cannot delte the entry before we sent that poor guy back to his hq
$db->query("UPDATE kills SET processed = 'TRUE' WHERE game_id = {$player->game_id} AND dead_id = {$killed_id} AND killer_id = {$killer_id}");