本文整理匯總了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);
}
}