本文整理汇总了PHP中Expression::isTrue方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::isTrue方法的具体用法?PHP Expression::isTrue怎么用?PHP Expression::isTrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::isTrue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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));
}
示例3: testQuery
public function testQuery()
{
$criteria = Criteria::create(TestUser::dao())->setProjection(Projection::property('id'))->add(Expression::isTrue('id'));
$this->assertCriteria('id from TestUser where id is true', $criteria)->assertCriteria('id from TestUser where id is true order by id asc', $criteria->addOrder(OrderBy::create('id')->asc()))->assertCriteria('id from TestUser where id is true order by id asc limit 10 offset 1', $criteria->setLimit(10)->setOffset(1))->assertCriteria('id from TestUser where id is true group by id order by id asc limit 10 offset 1', $criteria->setProjection(Projection::chain()->add(Projection::property('id'))->add(Projection::group('id'))))->assertCriteria('id from TestUser where id is true group by id order by id asc having id = 1 limit 10 offset 1', $criteria->setProjection(Projection::chain()->add(Projection::property('id'))->add(Projection::group('id'))->add(Projection::having(Expression::eq('id', 1)))))->assertCriteria('count(id) as count from TestUser group by id having count = 2', Criteria::create(TestUser::dao())->setProjection(Projection::chain()->add(Projection::count('id', 'count'))->add(Projection::group('id'))->add(Projection::having(Expression::eq('count', 2)))));
}