本文整理汇总了PHP中Expression::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::add方法的具体用法?PHP Expression::add怎么用?PHP Expression::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: increment
public static function increment(DAOConnected &$object, array $fields, $refreshCurrent = true, $query = null)
{
$objectDao = $object->dao();
if ($query) {
$updateQuery = $query;
} else {
$updateQuery = OSQL::update()->setTable($objectDao->getTable())->where(Expression::eqId('id', $object));
}
$mapping = $objectDao->getProtoClass()->getMapping();
foreach ($mapping as $field => $column) {
if (isset($fields[$field])) {
$updateQuery->set($column, Expression::add($column, $fields[$field]));
}
}
$updateCount = DBPool::getByDao($objectDao)->queryCount($updateQuery);
if ($query) {
$objectDao->uncacheLists();
} else {
$objectDao->uncacheById($object->getId());
}
if ($refreshCurrent && !$query) {
$object = $objectDao->getById($object->getId());
}
return $updateCount;
}
示例2: testHaving
public function testHaving()
{
$query = OQL::select('from TestUser');
$criteria = Criteria::create(TestUser::dao());
$this->assertCriteria($query->addHaving(OQL::having('id > 0')), $criteria->addProjection(Projection::having(Expression::gt('id', 0))));
$this->assertCriteria($query->addHaving(OQL::having('name is not null and (id <> $1 or id != $2)')->bindNext(4)->bindNext(8)), $criteria->addProjection(Projection::having(Expression::expAnd(Expression::notNull('name'), Expression::expOr(Expression::notEq('id', 4), Expression::notEq('id', 8))))));
$this->assertEquals(OQL::having('id + $15')->bind(15, 16)->toProjection(), Projection::having(Expression::add('id', 16)));
$this->assertCriteria(OQL::select('from TestUser')->addHaving(OQL::having('id = $1')->bindNext(23))->bindNext(42), Criteria::create(TestUser::dao())->addProjection(Projection::having(Expression::eq('id', 42))));
}
示例3: testFormCalculation
public function testFormCalculation()
{
$form = Form::create()->add(Primitive::string('a'))->add(Primitive::boolean('b'))->add(Primitive::integer('c'))->add(Primitive::integer('d'))->add(Primitive::integer('e'))->add(Primitive::boolean('f'))->import(array('a' => 'asDfg', 'b' => 'true', 'c' => '1', 'd' => '2', 'e' => '3'));
$this->assertTrue(Expression::isTrue(new FormField('b'))->toBoolean($form));
$this->assertFalse(Expression::isTrue(new FormField('f'))->toBoolean($form));
$this->assertFalse(Expression::eq('asdf', new FormField('a'))->toBoolean($form));
$this->assertTrue(Expression::eqLower('asdfg', new FormField('a'))->toBoolean($form));
$this->assertTrue(Expression::eq('asDfg', new FormField('a'))->toBoolean($form));
$this->assertTrue(Expression::andBlock(Expression::expOr(new FormField('b'), new FormField('f')), Expression::eq(7, Expression::add(new FormField('c'), Expression::mul(new FormField('d'), new FormField('e')))))->toBoolean($form));
$this->assertTrue(Expression::between(new FormField('d'), new FormField('c'), new FormField('e'))->toBoolean($form));
$this->assertFalse(Expression::between(new FormField('c'), new FormField('d'), new FormField('e'))->toBoolean($form));
$this->assertFalse(Expression::not(new FormField('b'))->toBoolean($form));
$this->assertTrue(Expression::not(new FormField('f'))->toBoolean($form));
}
示例4: toSelectQuery
public function toSelectQuery()
{
if (!$this->range || !$this->interval) {
throw new WrongStateException('define time range and interval units first');
}
if (!$this->range->getStart() || !$this->range->getEnd()) {
throw new WrongArgumentException('cannot operate with unlimited range');
}
$firstIntervalStart = $this->interval->truncate($this->range->getStart(), !$this->overlapped);
$maxIntervals = $this->interval->countInRange($this->range, $this->overlapped) - 1;
$generator = $this->getSeriesGenerator(0, $maxIntervals);
$result = OSQL::select()->from($generator, self::ITERATOR_ALIAS)->get(Expression::add(DBValue::create($firstIntervalStart->toString())->castTo(DataType::create(DataType::TIMESTAMP)->getName()), Expression::mul(DBValue::create("1 {$this->interval->getName()}")->castTo(DataType::create(DataType::INTERVAL)->getName()), DBField::create(self::ITERATOR_ALIAS))), $this->field);
return $result;
}
示例5: testHaving
public function testHaving()
{
$this->assertCriteria('from TestUser having (2 + -id --1) / 2 = id', Criteria::create(TestUser::dao())->setProjection(Projection::having(Expression::eq(Expression::div(Expression::sub(Expression::add(2, Expression::minus('id')), -1), 2), 'id'))), array(1 => 'id'))->assertCriteria('from TestUser having (id = 1) != ((1 = id) = (id >= 2))', Criteria::create(TestUser::dao())->setProjection(Projection::having(Expression::notEq(Expression::eq('id', 1), Expression::eq(Expression::eq(1, 'id'), Expression::gtEq('id', 2))))))->assertCriteria('from TestUser having $1 = 1', Criteria::create(TestUser::dao())->setProjection(Projection::having(Expression::eq(SQLFunction::create('count', 'id'), 1))), array(1 => SQLFunction::create('count', 'id')));
}