本文整理汇总了PHP中Expression::not方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::not方法的具体用法?PHP Expression::not怎么用?PHP Expression::not使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::not方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBoolean
public function testBoolean()
{
$this->create();
foreach (DBTestPool::me()->getPool() as $connector => $db) {
DBPool::me()->setDefault($db);
//creating moscow
$moscow = TestCity::create()->setName('Moscow');
$moscow = $moscow->dao()->add($moscow);
$moscowId = $moscow->getId();
/* @var $moscow TestCity */
//now moscow capital
$moscow->dao()->merge($moscow->setCapital(true));
TestCity::dao()->dropIdentityMap();
Criteria::create(TestCity::dao())->setSilent(false)->add(Expression::isTrue('capital'))->get();
TestCity::dao()->dropIdentityMap();
$moscow = Criteria::create(TestCity::dao())->setSilent(false)->add(Expression::isNull('large'))->get();
TestCity::dao()->dropIdentityMap();
//now moscow large
$moscow = $moscow->dao()->merge($moscow->setLarge(true));
TestCity::dao()->dropIdentityMap();
$moscow = TestCity::dao()->getById($moscowId);
$this->assertTrue($moscow->getCapital());
$this->assertTrue($moscow->getLarge());
Criteria::create(TestCity::dao())->setSilent(false)->add(Expression::not(Expression::isFalse('large')))->get();
TestCity::dao()->dropIdentityMap();
}
$this->drop();
}
示例2: testWhere
public function testWhere()
{
$query = OQL::select('from TestUser');
$criteria = Criteria::create(TestUser::dao());
$this->assertCriteria($query->andWhere(OQL::where('id = 1')), $criteria->add(Expression::eq('id', 1)));
$this->assertCriteria($query->orWhere(OQL::where('id = 2 and city.id is not null')), Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::eq('id', 1), Expression::expAnd(Expression::eq('id', 2), Expression::notNull('city.id')))));
$this->assertEquals(OQL::where('name similar to "test" and not $1')->bindNext('name')->toLogic(), Expression::expAnd(Expression::similar('name', 'test'), Expression::not('name')));
$this->assertCriteria(OQL::select('from TestUser')->where(OQL::where('id > $1')->bindNext(1))->bindNext(2), Criteria::create(TestUser::dao())->add(Expression::gt('id', 2)));
}
示例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: testWhere
public function testWhere()
{
$userId = 1;
$user = TestUser::create()->setId($userId);
$this->assertCriteria('from TestUser where id = $1 or id = $2 or $2 = id or $1 = $2', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::expOr(Expression::expOr(Expression::eqId('id', $user), Expression::eq('id', $userId)), Expression::eq($userId, 'id')), Expression::eq($userId, $userId))), array(1 => $user, 2 => $userId))->assertCriteria('from TestUser where id = 1 or id >= 1 or id <= 1 or id <> 1 or id != 1', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::expOr(Expression::expOr(Expression::expOr(Expression::eq('id', 1), Expression::gtEq('id', 1)), Expression::ltEq('id', 1)), Expression::notEq('id', 1)), Expression::notEq('id', 1))))->assertCriteria('from TestUser where id = 1 and Name = "some" ' . 'or Name = "any" or id = 1 > 2 = id * 2 + 1', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::expOr(Expression::expAnd(Expression::eq('id', 1), Expression::eq('Name', 'some')), Expression::eq('Name', 'any')), Expression::gt(Expression::eq('id', 1), Expression::eq(2, Expression::add(Expression::mul('id', 2), 1))))))->assertCriteria('from TestUser where (id = 1 and (Name = "some" or Name = "any"))', Criteria::create(TestUser::dao())->add(Expression::expAnd(Expression::eq('id', 1), Expression::expOr(Expression::eq('Name', 'some'), Expression::eq('Name', 'any')))))->assertCriteria('from TestUser where ((Name = "some" or Name = "any")) and (id = 1)', Criteria::create(TestUser::dao())->add(Expression::expAnd(Expression::expOr(Expression::eq('Name', 'some'), Expression::eq('Name', 'any')), Expression::eq('id', 1))))->assertCriteria('from TestUser where (id = 1) != ((1 = id) = (id >= 2))', Criteria::create(TestUser::dao())->add(Expression::notEq(Expression::eq('id', 1), Expression::eq(Expression::eq(1, 'id'), Expression::gtEq('id', 2)))))->assertCriteria('from TestUser where not (not not id = 1 and not id > 1)', Criteria::create(TestUser::dao())->add(Expression::not(Expression::expAnd(Expression::not(Expression::not(Expression::eq('id', 1))), Expression::not(Expression::gt('id', 1))))))->assertCriteria('from TestUser where id is null or id is not null or id is true or id is false', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::expOr(Expression::expOr(Expression::isNull('id'), Expression::notNull('id')), Expression::isTrue('id')), Expression::isFalse('id'))))->assertCriteria('from TestUser where id in (1) or id not in (1, "2", $1, true)', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::in('id', array(1)), Expression::notIn('id', array(1, '2', true, true)))), array(1 => true))->assertCriteria('from TestUser where id in ($1)', Criteria::create(TestUser::dao())->add(Expression::in('id', Criteria::create(TestUser::dao())->setProjection(Projection::property('id')))), array(1 => OQL::select('id from TestUser')->toCriteria()))->assertCriteria('from TestUser where id in ($1)', Criteria::create(TestUser::dao())->add(Expression::in('id', array(1, 2))), array(1 => array(1, 2)))->assertCriteria('from TestUser where id like $1 or id not like "Ы%" ' . 'or id ilike $2 or id not ilike "ы%" ' . 'or Name similar to "s" or Name not similar to $3', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::expOr(Expression::expOr(Expression::expOr(Expression::expOr(Expression::like('id', 'ы'), Expression::notLike('id', 'Ы%')), Expression::ilike('id', 'Ы')), Expression::notIlike('id', 'ы%')), Expression::similar('Name', 's')), Expression::notSimilar('Name', 'S'))), array(1 => 'ы', 2 => 'Ы', 3 => 'S'))->assertCriteria('from TestUser where created between "2008-08-06 10:00" and $1 ' . 'or id between id and 10', Criteria::create(TestUser::dao())->add(Expression::expOr(Expression::between('created', '2008-08-06 10:00', SQLFunction::create('now')), Expression::between('id', 'id', 10))), array(1 => SQLFunction::create('now')))->assertCriteria('from TestUser where (2 + -id --1) / 2 = id', Criteria::create(TestUser::dao())->add(Expression::eq(Expression::div(Expression::sub(Expression::add(2, Expression::minus('id')), -1), 2), 'id')), array(1 => 'id'));
}