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);
 }
Ejemplo n.º 2
0
 /**
  * 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);
 }