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


PHP Expression::div方法代码示例

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


在下文中一共展示了Expression::div方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testProperties

 public function testProperties()
 {
     $query = OQL::select('from TestUser');
     $criteria = Criteria::create(TestUser::dao());
     $this->assertCriteria($query, $criteria);
     $this->assertCriteria($query->addProperties(OQL::properties('id, count(id) as count')), $criteria->addProjection(Projection::property('id'))->addProjection(Projection::count('id', 'count')));
     $this->assertCriteria($query->addProperties(OQL::properties('city.id')), $criteria->addProjection(Projection::property('city.id')));
     $properties = OQL::properties('id');
     $this->assertFalse($properties->isDistinct());
     $this->assertEquals($properties->toProjection(), Projection::chain()->add(Projection::property('id')));
     $properties = OQL::properties('id, distinct name');
     $this->assertTrue($properties->isDistinct());
     $this->assertEquals($properties->toProjection(), Projection::chain()->add(Projection::property('id'))->add(Projection::property('name')));
     $properties = OQL::properties('$1')->bind(1, 'foo');
     $this->assertEquals($properties->toProjection(), Projection::chain()->add(Projection::property('foo')));
     $properties->bind(1, 'bar');
     $this->assertEquals($properties->toProjection(), Projection::chain()->add(Projection::property('bar')));
     $this->assertCriteria(OQL::select('from TestUser')->addProperties($properties->bind(1, 'foo'))->bind(1, 'bar'), Criteria::create(TestUser::dao())->addProjection(Projection::property('bar')));
     $properties = OQL::properties('id, count(distinct city.id + $0), avg(some) as someAverage, ' . 'name not like "%Ы%", foo and (bar or baz), $1 / $2, ' . 'a in ($3, $0)')->bindAll(array(1, 2, 'num', 'test'));
     $this->assertFalse($properties->isDistinct());
     $this->assertEquals($properties->toProjection(), Projection::chain()->add(Projection::property('id'))->add(Projection::distinctCount(Expression::add('city.id', 1)))->add(Projection::avg('some', 'someAverage'))->add(Projection::property(Expression::notLike('name', '%Ы%')))->add(Projection::property(Expression::expAnd('foo', Expression::expOr('bar', 'baz'))))->add(Projection::property(Expression::div(2, 'num')))->add(Projection::property(Expression::in('a', array('test', 1)))));
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:22,代码来源:OqlSelectClauseTest.class.php

示例2: testPgGeneration

 public function testPgGeneration()
 {
     $dialect = $this->getDbByType('PgSQL')->getDialect();
     $this->assertRegExp('/^\\(\\(\\(\\(\'asdf\' = "b"\\) (AND|and) \\("e" != \\("i" \\/ \'123\'\\)\\) (AND|and) \\(\\(lower\\("a"\\) += +lower\\("b"\\)\\) ((IS TRUE)|(is true))\\) (AND|and) \\("g" = \'12\'\\) (AND|and) \\("j" (BETWEEN|between) \'3\' (AND|and) "p"\\)\\) (OR|or) \\("table"\\."c" ((IS NOT NULL)|(is not null))\\)\\) (AND|and) \\("sometable"\\."a" ((not in)|(NOT IN)) \\(\'q\', \'qwer\', \'xcvzxc\', \'wer\'\\)\\)\\)$/', Expression::expAnd(Expression::expOr(Expression::andBlock(Expression::eq(new DBValue('asdf'), new DBField('b')), Expression::notEq(new DBField('e'), Expression::div(new DBField('i'), new DBValue(123))), Expression::isTrue(Expression::eqLower(new DBField('a'), new DBField('b'))), Expression::eq(new DBField('g'), new DBValue(12)), Expression::between('j', new DBValue(3), new DBField('p'))), Expression::notNull(new DBField('c', 'table'))), Expression::notIn(new DBField('a', 'sometable'), array('q', 'qwer', 'xcvzxc', 'wer')))->toDialectString($dialect));
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:5,代码来源:LogicTest.class.php

示例3: 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')));
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:4,代码来源:OqlSelectTest.class.php


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