本文整理汇总了PHP中ConnectionFactory::InsertOnDuplicateKeyUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionFactory::InsertOnDuplicateKeyUpdate方法的具体用法?PHP ConnectionFactory::InsertOnDuplicateKeyUpdate怎么用?PHP ConnectionFactory::InsertOnDuplicateKeyUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionFactory
的用法示例。
在下文中一共展示了ConnectionFactory::InsertOnDuplicateKeyUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateUserBlackmarketItems
public function updateUserBlackmarketItems($userID, $bmID, $quantity)
{
$itemParams = array();
$itemParams['user_id'] = $userID;
$itemParams['item_id'] = $bmID;
$itemParams['quantity'] = $quantity + 1;
// print_r($itemParams);
//for this to work, need to modify appropriate tables to have unique constraint over two columns
//http://www.w3schools.com/sql/sql_unique.asp
//although i think the two primary keys are doing it
if (ConnectionFactory::InsertOnDuplicateKeyUpdate("users_items", $itemParams, "quantity", 1)) {
return 1;
}
return 0;
//echo $val;
//die();
}
示例2: updateDailyBonus
public function updateDailyBonus($amount, $numConsecDays)
{
if ($numConsecDays < 6) {
$params = array();
$params['user_id'] = $this->id;
$dayString = 'day' . ($numConsecDays + 1);
$params[$dayString] = $amount;
return ConnectionFactory::InsertOnDuplicateKeyUpdate("users_dailybonuses", $params, $dayString, $amount);
} else {
$params = array();
for ($i = 1; $i <= 6; $i++) {
$params['day' . $i] = 0;
}
$conditions = array();
$conditions['user_id'] = $this->id;
return ConnectionFactory::updateTableRowAbsoluteBasic("users_dailybonuses", $params, $conditions);
}
}