本文整理汇总了PHP中Expression类的典型用法代码示例。如果您正苦于以下问题:PHP Expression类的具体用法?PHP Expression怎么用?PHP Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compileType
protected function compileType(&$code, Expression $typeExpression)
{
if ($typeExpression instanceof ValueExpression) {
$code .= $typeExpression->getValue();
} else {
$typeExpression->compileCode($code);
}
}
示例2: getNextOccurrence
/**
* Returns the next valid date after the provided $dateTime object.
*
* @param DateTime $dateTime
* @return DateTime
*/
public function getNextOccurrence(\DateTime $dateTime)
{
$firstNextOccurrnece = $this->firstExpression->getNextOccurrence($dateTime);
if (!$this->contains($firstNextOccurrnece)) {
$firstNextOccurrnece = $this->getNextOccurrence($firstNextOccurrnece);
}
return $firstNextOccurrnece;
}
示例3: addCondition
/**
* @param mixed $value
* @param string $operator
* @param boolean $iscolumn
*/
protected function addCondition($value, $operator, $iscolumn)
{
if ($iscolumn && is_string($value)) {
$expr = new Expression($this->compiler);
$value = $expr->column($value);
}
$this->havingClause->addCondition($this->aggregate, $value, $operator, $this->separator);
}
示例4: add
/**
* add
*
* @param Expression $expr
* @access public
* @return void
*/
public function add(Expression $expr)
{
if (!$expr instanceof OrderExpression) {
throw new \InvalidArgumentException('OrderClause only accept OrderExpression as its part.');
}
// internal Expression has to be an unique by field
$this->expressions[$expr->getField()->getName()] = $expr;
return $this;
}
示例5: test_caching
public function test_caching()
{
$e = '$_0 < $_1';
$x = new Expression($e);
// different objects w/ same expression...
$y = new Expression($e);
// ... should have same callable
$this->assertSame($x->getCallable(), $y->getCallable());
}
示例6: compileCode
protected function compileCode(&$code)
{
if ($this->name instanceof ValueExpression && self::isNormalSyntaxName($this->name->getValue())) {
$code .= '$' . $this->name->getValue();
} else {
$code .= '${';
$this->name->compileCode($code);
$code .= '}';
}
}
示例7: compileCode
protected function compileCode(&$code)
{
if ($this->name instanceof ValueExpression) {
$code .= $this->name->getValue();
} else {
$this->name->compileCode($code);
}
$code .= '(';
$code .= implode(',', self::compileAll($this->arguments));
$code .= ')';
}
示例8: compileCode
protected function compileCode(&$code)
{
$code .= '(';
$this->leftOperand->compileCode($code);
$code .= ' ' . $this->operator . ' ';
if ($this->operator === Operators\Binary::IS_INSTANCE_OF && $this->rightOperand instanceof ValueExpression) {
$code .= $this->rightOperand->getValue();
} else {
$this->rightOperand->compileCode($code);
}
$code .= ')';
}
示例9: quoteTable
public function quoteTable($value)
{
if ($value instanceof Criterion) {
$value = new Expression('( ' . $value->createSql() . ' )');
}
if ($value instanceof Expression) {
return $value->toString();
}
$this->separator = '';
$this->implodeGlue = '.';
return $this->_quote(explode('.', $value));
}
示例10: evaluate
/**
* @param RuleConditionExpression $rce
* @param array $contextMap
* @return mixed
*/
function evaluate($rce, $contextMap)
{
$operator = strtoupper($rce->operator);
$evaluator = $this->getEvaluator($operator);
if (!$evaluator) {
throw new MockApiException("unsupported condition operator '" . $operator . '"', ErrorInfo::UNSUPPORTED_CONDITION_OPERATOR);
}
$exp = new Expression();
$exp->setLeft($this->getOperandValue($rce->left, $contextMap));
$exp->setRight($this->getOperandValue($rce->right, $contextMap));
$exp->setOperator($operator);
return $evaluator->evaluate($exp);
}
示例11: getFilteredResultSet
function getFilteredResultSet(&$masterResultSet, &$sqlQuery)
{
global $g_sqlSingleRecFuncs;
$parser = new SqlParser($sqlQuery->where_expr);
$king_expr = new Expression();
$current_expr =& $king_expr;
while (!is_empty_str($elem = $parser->parseNextElementRaw())) {
// function ?
if (in_array(strtoupper($elem), $g_sqlSingleRecFuncs)) {
$current_expr->expr_str .= $elem;
$elem = $parser->parseNextElementRaw();
if ($elem != "(") {
print_error_msg("( expected after " . $current_expr->expr_str);
return null;
}
$current_expr->expr_str .= $elem;
while (!is_empty_str($elem = $parser->parseNextElementRaw()) && $elem != ")") {
$current_expr->expr_str .= $elem;
}
$current_expr->expr_str .= $elem . " ";
continue;
}
if ($elem == "(") {
$current_expr->expr_str .= " % ";
unset($new_expr);
$new_expr = new Expression("");
$current_expr->addChild($new_expr);
$new_expr->setParent($current_expr);
unset($current_expr);
$current_expr =& $new_expr;
} else {
if ($elem == ")") {
unset($tmp);
$tmp =& $current_expr->getParent();
unset($current_expr);
$current_expr =& $tmp;
} else {
// no spaces on .'s
if ($elem == ".") {
remove_last_char($current_expr->expr_str);
$current_expr->expr_str .= $elem;
} else {
$current_expr->expr_str .= $elem . " ";
}
}
}
}
return $king_expr->getFilteredResultSet($masterResultSet, $sqlQuery);
}
示例12: compileCode
protected function compileCode(&$code)
{
$this->value->compileCode($code);
$code .= '->';
if ($this->name instanceof ValueExpression && self::isNormalSyntaxName($this->name->getValue())) {
$code .= $this->name->getValue();
} else {
$code .= '{';
$this->name->compileCode($code);
$code .= '}';
}
$code .= '(';
$code .= implode(',', self::compileAll($this->arguments));
$code .= ')';
}
示例13: testErrors
public function testErrors()
{
$form = Form::create()->add(Primitive::ternary('flag')->setFalseValue('0')->setTrueValue('1'))->add(Primitive::integer('old')->required())->addRule('someRule', Expression::between(FormField::create('old'), '18', '35'));
//empty import
$form->import(array())->checkRules();
//checking
$expectingErrors = array('old' => Form::MISSING, 'someRule' => Form::WRONG);
$this->assertEquals($expectingErrors, $form->getErrors());
$this->assertEquals(Form::MISSING, $form->getError('old'));
$this->assertEquals(Form::WRONG, $form->getError('someRule'));
$this->assertTrue($form->hasError('old'));
$this->assertFalse($form->hasError('flag'));
//drop errors
$form->dropAllErrors();
$this->assertEquals(array(), $form->getErrors());
//import wrong data
$form->clean()->importMore(array('flag' => '3', 'old' => '17'))->checkRules();
//checking
$expectingErrors = array('flag' => Form::WRONG, 'someRule' => Form::WRONG);
$this->assertEquals($expectingErrors, $form->getErrors());
$this->assertTrue($form->hasError('someRule'));
//marking good and custom check errors
$form->markGood('someRule')->markCustom('flag', 3);
$this->assertEquals(array('flag' => 3), $form->getErrors());
$this->assertFalse($form->hasError('someRule'));
$this->assertNull($form->getError('someRule'));
$this->assertEquals(3, $form->getError('flag'));
//import right data
$form->dropAllErrors()->clean()->importMore(array('flag' => '1', 'old' => '35'));
//checking
$this->assertEquals(array(), $form->getErrors());
}
示例14: testInsertFromSelect
public function testInsertFromSelect()
{
$dialect = $this->getDbByType('PgSQL')->getDialect();
$select = OSQL::select()->from('test_table2')->get('field3')->get('field_7')->andWhere(Expression::gt('field2', DBValue::create('33')));
$insert = OSQL::insert()->setSelect($select)->into('test_table')->set('field2', 2)->set('field16', 3);
$this->assertEquals($insert->toDialectString($dialect), 'INSERT INTO "test_table" ("field2", "field16") (' . 'SELECT "test_table2"."field3", "test_table2"."field_7" ' . 'FROM "test_table2" WHERE ("field2" > \'33\')' . ')');
}
示例15: getStyle
/**
* Get style of element
*
* @return string style of Element
*/
protected function getStyle()
{
$htmlClass = $this->m_cssClass ? "class='" . $this->m_cssClass . "' " : "class='editcombobox'";
/*
$width = $this->m_Width ? $this->m_Width : 146;
$this->m_WidthInput = ($width-18).'px';
$this->m_Width = $width.'px';
$style = "position: absolute; width: $this->m_Width; z-index: 1; clip: rect(auto, auto, auto, $this->m_WidthInput);";
*/
if ($this->m_Style) {
$style .= $this->m_Style;
}
if (!isset($style) && !$htmlClass) {
return null;
}
if (isset($style)) {
$formObj = $this->getFormObj();
$style = Expression::evaluateExpression($style, $formObj);
$style = "style='{$style}'";
}
if ($htmlClass) {
$style = $htmlClass . " " . $style;
}
return $style;
}