本文整理汇总了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)))));
}
示例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));
}
示例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')));
}