Exemplo n.º 1
0
 /**
  * Given a SELECT statement that uses click count
  * returns the corresponding update sql string
  * for databases that don't have click count support built in
  * (aka all besides CUBRID)
  *
  * Function does not check if click count columns exist!
  * You must call $query->usesClickCount() before using this function
  *
  * @param $queryObject
  */
 function getClickCountQuery($queryObject)
 {
     $new_update_columns = array();
     $click_count_columns = $queryObject->getClickCountColumns();
     foreach ($click_count_columns as $click_count_column) {
         $click_count_column_name = $click_count_column->column_name;
         $increase_by_1 = new Argument($click_count_column_name, null);
         $increase_by_1->setColumnOperation('+');
         $increase_by_1->ensureDefaultValue(1);
         $update_expression = new UpdateExpression($click_count_column_name, $increase_by_1);
         $new_update_columns[] = $update_expression;
     }
     $queryObject->columns = $new_update_columns;
     return $queryObject;
 }
Exemplo n.º 2
0
 public function testEnsureDefaultValueWithEmptyString()
 {
     $homepage_argument = new Argument('homepage', '');
     $homepage_argument->ensureDefaultValue('');
     $homepage_argument->checkFilter('homepage');
     if (!$homepage_argument->isValid()) {
         return $homepage_argument->getErrorMessage();
     }
     $homepage_argument->setColumnType('varchar');
     $this->assertEquals('\'\'', $homepage_argument->getValue());
 }