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