本文整理汇总了PHP中XDB::insertID方法的典型用法代码示例。如果您正苦于以下问题:PHP XDB::insertID方法的具体用法?PHP XDB::insertID怎么用?PHP XDB::insertID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDB
的用法示例。
在下文中一共展示了XDB::insertID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vote
public function vote($answer)
{
XDB::startTransaction();
XDB::execute('INSERT INTO qdj_votes
SET qdj = {?}, uid = {?}, rank = 0, rule = "null"', $this->id(), S::user()->id());
$vote = XDB::insertID();
// Get the rank
$rank = XDB::query('SELECT COUNT(*)+1
FROM qdj_votes
WHERE qdj = {?} AND rank != 0', $this->id())->fetchOneCell();
if ($rank == 1) {
if ($this->writer === null) {
$this->select(QDJSelect::all());
}
XDB::execute('INSERT INTO qdj_votes
SET qdj = {?}, uid = {?}, rank = 0, rule = 10', $this->id(), $this->writer->id());
}
$rule = null;
switch ($rank) {
case 1:
$rule = '1';
break;
case 2:
$rule = '2';
break;
case 3:
$rule = '3';
break;
case 13:
$rule = '4';
break;
case 42:
$rule = '5';
break;
case 69:
$rule = '6';
break;
case 314:
$rule = '7';
break;
case substr(strrchr(IPAddress::get(), '.'), 1):
$rule = '8';
break;
case date('d') + date('m'):
$rule = '9';
break;
}
XDB::execute('UPDATE qdj_votes
SET rank = {?}, rule = {?}
WHERE vote_id = {?}', $rank, $rule, $vote);
XDB::commit();
if ($answer == 1) {
XDB::execute('UPDATE qdj SET count1 = count1+1 WHERE id={?}', $this->id());
} else {
XDB::execute('UPDATE qdj SET count2 = count2+1 WHERE id={?}', $this->id());
}
}