本文整理匯總了PHP中DBC::execute方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBC::execute方法的具體用法?PHP DBC::execute怎麽用?PHP DBC::execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBC
的用法示例。
在下文中一共展示了DBC::execute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAutoincrementsVsSerial
function testAutoincrementsVsSerial()
{
$prefix = OA_Dal::getTablePrefix();
$oDbh = OA_DB::singleton();
$table = $oDbh->quoteIdentifier($prefix . 'ad_category_assoc');
$sqlInsert = "INSERT INTO {$table} (category_id, ad_id) VALUES (1, 1)";
DBC::execute($sqlInsert);
// Take generated primary key
$doAd_category_assoc = OA_Dal::factoryDO('ad_category_assoc');
$doAd_category_assoc->find($aufetch = true);
$id1 = $doAd_category_assoc->ad_category_assoc_id;
// Now lets generate new record using DataGenerator
$id2 = DataGenerator::generateOne('ad_category_assoc');
// Not only above code should work but also id2 should be equal id1+1
$this->assertEqual($id2, $id1 + 1);
}
示例2: addConversion
/**
* TODO: Should we refactor this method in more general one?
* (maybe by creating common abstract class for all summary tables?)
*
* @param string $operation Either + or -
* @param int $basketValue
* @param int $numItems
* @param int $ad_id
* @param int $creative_id
* @param int $zone_id
* @param strin $day
* @param string $hour
* @return unknown
*/
function addConversion($operation, $basketValue, $numItems, $ad_id, $creative_id, $zone_id, $day, $hour, $table = null)
{
$prefix = $this->getTablePrefix();
if ($operation != '-') {
$operation = '+';
}
if ($table == null) {
$table = $this->table;
}
$oDbh = OA_DB::singleton();
$table = $oDbh->quoteIdentifier($prefix . $table, true);
$query = '
UPDATE ' . $table . ' SET conversions=conversions' . $operation . '1
, total_basket_value=total_basket_value' . $operation . DBC::makeLiteral($basketValue) . '
, total_num_items=total_num_items' . $operation . DBC::makeLiteral($numItems) . '
, updated = \'' . OA::getNow() . '\'
WHERE
ad_id = ' . DBC::makeLiteral($ad_id) . '
AND creative_id = ' . DBC::makeLiteral($creative_id) . '
AND zone_id = ' . DBC::makeLiteral($zone_id) . '
AND date_time = ' . DBC::makeLiteral(sprintf("%s %02d:00:00", $day, $hour));
return DBC::execute($query);
}