本文整理汇总了PHP中Expression类的典型用法代码示例。如果您正苦于以下问题:PHP Expression类的具体用法?PHP Expression怎么用?PHP Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Expression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: compileType
protected function compileType(&$code, Expression $typeExpression)
{
if ($typeExpression instanceof ValueExpression) {
$code .= $typeExpression->getValue();
} else {
$typeExpression->compileCode($code);
}
}
开发者ID:timetoogo,项目名称:pinq,代码行数:8,代码来源:StaticClassExpression.php
示例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;
}
开发者ID:robzienert,项目名称:TemporalExpression,代码行数:14,代码来源:Difference.php
示例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);
}
开发者ID:cgslivre,项目名称:database-1,代码行数:13,代码来源:Having.php
示例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;
}
开发者ID:o3co,项目名称:query,代码行数:16,代码来源:OrderClause.php
示例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());
}
开发者ID:haldayne,项目名称:fox,代码行数:9,代码来源:ExpressionTest.php
示例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 .= '}';
}
}
开发者ID:timetoogo,项目名称:pinq,代码行数:10,代码来源:VariableExpression.php
示例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 .= ')';
}
开发者ID:timetoogo,项目名称:pinq,代码行数:11,代码来源:FunctionCallExpression.php
示例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 .= ')';
}
开发者ID:timetoogo,项目名称:pinq,代码行数:12,代码来源:BinaryOperationExpression.php
示例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));
}
开发者ID:Eximagen,项目名称:sochi,代码行数:12,代码来源:MSSqlQuoteStrategy.php
示例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);
}
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:18,代码来源:RuleConditionExpressionEngine.php
示例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);
}
开发者ID:Kent-Liang,项目名称:Network-Security,代码行数:49,代码来源:expression.php
示例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 .= ')';
}
开发者ID:timetoogo,项目名称:pinq,代码行数:15,代码来源:MethodCallExpression.php
示例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());
}
开发者ID:rero26,项目名称:onphp-framework,代码行数:32,代码来源:FormTest.class.php
示例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\')' . ')');
}
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:7,代码来源:OsqlInsertTest.class.php
示例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;
}
开发者ID:que273,项目名称:siremis,代码行数:30,代码来源:EditCombobox.php
示例16: getSome
private function getSome()
{
for ($i = 1; $i < 3; ++$i) {
$this->assertTrue(TestUser::dao()->getByLogic(Expression::eq('city_id', $i)) == TestUser::dao()->getById($i));
}
$this->assertEquals(count(TestUser::dao()->getPlainList()), count(TestCity::dao()->getPlainList()));
}
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:7,代码来源:DataDBTest.class.php
示例17: testExpression
function testExpression()
{
// Expression 1
$exp = new Expression('x => x > 10');
$this->assertTrue($exp->execute(20));
$this->assertFalse($exp->execute(5));
// Expression 2 ( Lambda Expression )
$exp = new Expression(function ($x) {
return is_string($x);
});
$this->assertFalse($exp->execute(10));
$this->assertTrue($exp->execute('Hello'));
// Expression 3
$exp = new Expression('user => user->name == "Alireza" AND user->id == 12');
$this->assertTrue($exp->execute((object) ['name' => 'Alireza', 'id' => 12]));
}
开发者ID:mdzzohrabi,项目名称:azera-queryable,代码行数:16,代码来源:ExpressionTest.php
示例18: getStyle
protected function getStyle()
{
$formobj = $this->getFormObj();
$htmlClass = Expression::evaluateExpression($this->m_cssClass, $formobj);
$htmlClass = "CLASS='{$htmlClass}'";
if (!$htmlClass) {
$htmlClass = null;
}
$style = '';
if ($this->m_Style) {
$style .= $this->m_Style;
}
if (!isset($style) && !$htmlClass) {
return null;
}
if (isset($style)) {
$style = Expression::evaluateExpression($style, $formobj);
$style = "STYLE='{$style}'";
}
if ($formobj->m_Errors[$this->m_Name]) {
$htmlClass = "CLASS='" . $this->m_cssErrorClass . "'";
}
if ($htmlClass) {
$style = $htmlClass . " " . $style;
}
return $style;
}
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:27,代码来源:ColumnBar.php
示例19: dropList
public function dropList()
{
$dao = $this->container->getDao();
DBPool::getByDao($dao)->queryNull(OSQL::delete()->from($this->container->getHelperTable())->where(Expression::eq($this->container->getParentIdField(), $this->container->getParentObject()->getId())));
$dao->uncacheLists();
return $this;
}
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:7,代码来源:UnifiedContainerWorker.class.php
示例20: __construct
/**
* Initialize Node
*
* @param array $rec
* @return void
*/
function __construct($rec)
{
$this->m_Id = $rec['Id'];
$this->m_PId = $rec['PId'];
$this->m_Name = $rec['title'];
$this->m_Module = $rec['module'];
$this->m_Description = $rec['description'];
$this->m_URL = $rec['link'];
if (strpos($this->m_URL, '{') === 0) {
$this->m_URL = Expression::evaluateExpression($this->m_URL, $this);
} else {
if (!empty($this->m_URL)) {
if (strpos($this->m_URL, '/') === 0) {
$this->m_URL = APP_INDEX . $this->m_URL;
} else {
$this->m_URL = APP_INDEX . '/' . $this->m_URL;
}
}
}
$this->m_URL_Match = $rec['alias'];
//$this->m_CssClass = $rec['Id'];
$this->m_IconImage = $rec['icon'];
$this->m_IconCSSClass = $rec['icon_css'];
$this->m_Access = $rec['access'];
$this->translate();
// translate for multi-language support
}
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:33,代码来源:MenuRecord.php
注:本文中的Expression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论