当前位置: 首页>>代码示例>>PHP>>正文


PHP Expression::isNull方法代码示例

本文整理汇总了PHP中Expression::isNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::isNull方法的具体用法?PHP Expression::isNull怎么用?PHP Expression::isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Expression的用法示例。


在下文中一共展示了Expression::isNull方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:28,代码来源:DAOTest.class.php

示例2: getOpenPoint

 /**
  * @throws WrongArgumentException
  * @return LogicalChain
  **/
 public static function getOpenPoint($left, $right, $point)
 {
     Assert::isFalse($point === null, 'how can i build logic from emptyness?');
     $point = new DBValue($point);
     $chain = new LogicalChain();
     $chain->expOr(Expression::orBlock(Expression::andBlock(Expression::notNull($left), Expression::notNull($right), Expression::between($point, $left, $right)), Expression::andBlock(Expression::isNull($left), Expression::ltEq($point, $right)), Expression::andBlock(Expression::isNull($right), Expression::ltEq($left, $point)), Expression::andBlock(Expression::isNull($left), Expression::isNull($right))));
     return $chain;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:12,代码来源:LogicUtils.class.php

示例3: testBaseSqlGeneration

 public function testBaseSqlGeneration()
 {
     $dialect = ImaginaryDialect::me();
     $pgDialect = $this->getDbByType('PgSQL')->getDialect();
     $this->assertRegExp('/^\\(a (AND|and) b\\)$/', Expression::expAnd('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a (OR|or) b\\)$/', Expression::expOr('a', 'b')->toDialectString($dialect));
     $this->assertEquals(Expression::eq('a', 'b')->toDialectString($dialect), '(a = b)');
     $some = IdentifiableObject::wrap(123);
     $this->assertEquals(Expression::eqId('a', $some)->toDialectString($dialect), '(a = 123)');
     $this->assertEquals(Expression::notEq('a', 'b')->toDialectString($dialect), '(a != b)');
     $this->assertEquals(Expression::gt('a', 'b')->toDialectString($dialect), '(a > b)');
     $this->assertEquals(Expression::gtEq('a', 'b')->toDialectString($dialect), '(a >= b)');
     $this->assertEquals(Expression::lt('a', 'b')->toDialectString($dialect), '(a < b)');
     $this->assertEquals(Expression::ltEq('a', 'b')->toDialectString($dialect), '(a <= b)');
     $this->assertRegExp('/^\\(a ((IS NOT NULL)|(is not null)) *\\)$/', Expression::notNull('a')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((IS NULL)|(is null)) *\\)$/', Expression::isNull('a')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((IS TRUE)|(is true)) *\\)$/', Expression::isTrue('a')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((IS FALSE)|(is false)) *\\)$/', Expression::isFalse('a')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a (LIKE|like) b\\)$/', Expression::like('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((NOT LIKE)|(not like)) b\\)$/', Expression::notLike('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a (ILIKE|ilike) b\\)$/', Expression::ilike('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((NOT ILIKE)|(not like)) b\\)$/', Expression::notIlike('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((SIMILAR TO)|(similar to)) b\\)$/', Expression::similar('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((NOT SIMILAR TO)|(not similar to)) b\\)$/', Expression::notSimilar('a', 'b')->toDialectString($dialect));
     $this->assertEquals('(lower(a) = b)', Expression::eqLower('a', 'b')->toDialectString($dialect));
     $this->assertEquals('(lower(a) = lower(b))', Expression::eqLower(new DBValue('a'), new DBValue('b'))->toDialectString($dialect));
     $this->assertEquals('(lower(\'a\') = lower(\'b\'))', Expression::eqLower(new DBValue('a'), new DBValue('b'))->toDialectString($pgDialect));
     $this->assertEquals('(lower(\'a\') = lower("b"))', Expression::eqLower(new DBValue('a'), new DBField('b'))->toDialectString($pgDialect));
     $this->assertEquals('(lower("a") = lower(\'b\'))', Expression::eqLower(new DBField('a'), new DBValue('b'))->toDialectString($pgDialect));
     $this->assertRegExp('/^\\(a (BETWEEN|between) b (AND|and) c\\)$/', Expression::between('a', 'b', 'c')->toDialectString($dialect));
     $this->assertEquals('(a = 123)', Expression::in('a', 123)->toDialectString($dialect));
     $this->assertEquals('(a = 123)', Expression::in('a', array(123))->toDialectString($dialect));
     $this->assertRegExp('/^\\(a (in|IN) \\(123, 456\\)\\)$/', Expression::in('a', array(123, 456))->toDialectString($dialect));
     $this->assertEquals('(a != 123)', Expression::notIn('a', 123)->toDialectString($dialect));
     $this->assertEquals('(a != 123)', Expression::notIn('a', array(123))->toDialectString($dialect));
     $this->assertRegExp('/^\\(a ((not in)|(NOT IN)) \\(123, 456\\)\\)$/', Expression::notIn('a', array(123, 456))->toDialectString($dialect));
     $this->assertEquals('(a + b)', Expression::add('a', 'b')->toDialectString($dialect));
     $this->assertEquals('(a - b)', Expression::sub('a', 'b')->toDialectString($dialect));
     $this->assertEquals('(a * b)', Expression::mul('a', 'b')->toDialectString($dialect));
     $this->assertEquals('(a / b)', Expression::div('a', 'b')->toDialectString($dialect));
     $this->assertRegExp('/^\\(a (between|BETWEEN) b (and|AND) c\\)$/', Expression::between('a', 'b', 'c')->toDialectString($dialect));
     $this->assertEquals('(-1 IS NULL)', Expression::isNull(-1)->toDialectString($dialect));
     $this->assertEquals('(NOT a)', Expression::not('a')->toDialectString($dialect));
     $this->assertEquals('(- a)', Expression::minus('a')->toDialectString($dialect));
     try {
         Expression::eq('id', null)->toDialectString($dialect);
         $this->fail();
     } catch (WrongArgumentException $e) {
         //it's Ok
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:51,代码来源:LogicTest.class.php

示例4: orderDataProvider

 public static function orderDataProvider()
 {
     return array(array(OrderBy::create('id'), 'test_user.id'), array(OrderChain::create()->add(OrderBy::create('id')->asc())->add(OrderBy::create('id')), 'test_user.id ASC, test_user.id'), array(OrderBy::create('id')->asc(), 'test_user.id ASC'), array(OrderBy::create('id')->desc(), 'test_user.id DESC'), array(OrderBy::create('id')->nullsFirst(), 'test_user.id NULLS FIRST'), array(OrderBy::create('id')->nullsLast(), 'test_user.id NULLS LAST'), array(OrderBy::create('id')->asc()->nullsLast(), 'test_user.id ASC NULLS LAST'), array(OrderBy::create('id')->desc()->nullsFirst(), 'test_user.id DESC NULLS FIRST'), array(OrderBy::create(Expression::isNull('id'))->asc()->nullsFirst(), '((test_user.id IS NULL)) ASC NULLS FIRST'));
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:4,代码来源:CriteriaTest.class.php

示例5: testOrderBy

 public function testOrderBy()
 {
     $this->assertCriteria('from TestUser order by id', Criteria::create(TestUser::dao())->addOrder(OrderBy::create('id')))->assertCriteria('from TestUser order by id asc, nickname desc', Criteria::create(TestUser::dao())->addOrder(OrderChain::create()->add(OrderBy::create('id')->asc())->add(OrderBy::create('nickname')->desc())))->assertCriteria('from TestUser order by $1, nickname is null, -id/2 + 1 asc ', Criteria::create(TestUser::dao())->addOrder(OrderChain::create()->add(OrderBy::create(SQLFunction::create('rand')))->add(OrderBy::create(Expression::isNull('nickname')))->add(OrderBy::create(Expression::add(Expression::div(Expression::minus('id'), 2), 1))->asc())), array(1 => SQLFunction::create('rand')));
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:OqlSelectTest.class.php


注:本文中的Expression::isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。