本文整理汇总了PHP中Argument::ensureDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Argument::ensureDefaultValue方法的具体用法?PHP Argument::ensureDefaultValue怎么用?PHP Argument::ensureDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Argument
的用法示例。
在下文中一共展示了Argument::ensureDefaultValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClickCountQuery
/**
* 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;
}
示例2: testEnsureDefaultValueWithEmptyString
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());
}