本文整理汇总了PHP中Expression::eq方法的典型用法代码示例。如果您正苦于以下问题:PHP Expression::eq方法的具体用法?PHP Expression::eq怎么用?PHP Expression::eq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression::eq方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dropList
public function dropList()
{
$dao = $this->container->getDao();
DBPool::getByDao($dao)->queryNull(OSQL::delete()->from($this->container->getHelperTable())->where(Expression::eq($this->container->getParentIdField(), $this->container->getParentObject()->getId())));
$dao->uncacheLists();
return $this;
}
示例2: getSome
private function getSome()
{
for ($i = 1; $i < 3; ++$i) {
$this->assertTrue(TestUser::dao()->getByLogic(Expression::eq('city_id', $i)) == TestUser::dao()->getById($i));
}
$this->assertEquals(count(TestUser::dao()->getPlainList()), count(TestCity::dao()->getPlainList()));
}
示例3: joinHelperTable
/**
* @return SelectQuery
**/
protected function joinHelperTable(SelectQuery $query)
{
$uc = $this->container;
if (!$query->hasJoinedTable($uc->getHelperTable())) {
$query->join($uc->getHelperTable(), Expression::eq(new DBField($uc->getParentTableIdField(), $uc->getDao()->getTable()), new DBField($uc->getChildIdField(), $uc->getHelperTable())));
}
return $query->andWhere(Expression::eq(new DBField($uc->getParentIdField(), $uc->getHelperTable()), new DBValue($uc->getParentObject()->getId())));
}
示例4: testLazy
public function testLazy()
{
foreach (DBTestPool::me()->getPool() as $db) {
DBPool::me()->setDefault($db);
$parent = TestParentObject::create();
$child = TestChildObject::create()->setParent($parent);
$parent->dao()->add($parent);
$child->dao()->add($child);
$this->assertEquals($parent->getId(), Criteria::create(TestChildObject::dao())->setProjection(Projection::property('parent.id', 'parentId'))->add(Expression::eq('id', $child->getId()))->getCustom('parentId'));
}
}
示例5: testHasNoReturning
public function testHasNoReturning()
{
$dialect = ImaginaryDialect::me();
$query = OSQL::update('test_table')->set('field1', 1)->where(Expression::eq('field1', 2))->returning('field1');
try {
$query->toDialectString($dialect);
} catch (UnimplementedFeatureException $e) {
return $this;
}
$this->fail();
}
示例6: testIpRangeProperty
public function testIpRangeProperty()
{
foreach (DBTestPool::me()->getPool() as $db) {
DBPool::me()->setDefault($db);
$akado = TestInternetProvider::create()->setName('Akada')->setRange(IpRange::create(IpAddress::create('192.168.1.1'), IpAddress::create('192.168.1.42')));
TestInternetProvider::dao()->add($akado);
$plainRange = Criteria::create(TestInternetProvider::dao())->addProjection(Projection::property('range'))->add(Expression::eq('name', 'Akada'))->getCustom();
$this->assertEquals($plainRange['range'], '192.168.1.1-192.168.1.42');
TestInternetProvider::dao()->add(TestInternetProvider::create()->setName('DomRu')->setRange(IpRange::create('192.168.2.0/24')));
$list = Criteria::create(TestInternetProvider::dao())->addOrder('id')->getList();
$this->assertEquals(count($list), 2);
}
}
示例7: testQuery
public function testQuery()
{
$query = OSQL::delete()->from('pity_table');
$dialect = PostgresDialect::me();
try {
$query->toDialectString($dialect);
$this->fail();
} catch (WrongArgumentException $e) {
/* pass */
}
$query->where(Expression::eq('count', 2));
$this->assertEquals($query->toDialectString($dialect), 'DELETE FROM "pity_table" WHERE ("count" = \'2\')');
$query->andWhere(Expression::notEq('a', '2'));
$this->assertEquals($query->toDialectString($dialect), 'DELETE FROM "pity_table" WHERE ("count" = \'2\') AND ("a" != \'2\')');
}
示例8: testSelectJoin
public function testSelectJoin()
{
$dialect = $this->getDbByType('PgSQL')->getDialect();
$joinTypeList = array('JOIN ' => 'join', 'LEFT JOIN ' => 'leftJoin', 'RIGHT JOIN ' => 'rightJoin', 'FULL OUTER JOIN ' => 'fullOuterJoin');
$joinExpression = Expression::eq(DBField::create('joinField', 'table1'), DBField::create('joinField', 'table2'));
$baseRawQuery = 'SELECT ' . '"table1"."field1", ' . '"table2"."field2" ' . 'FROM "table1" ';
foreach ($joinTypeList as $sqlJoin => $method) {
$query = $this->getBaseJoinSelect()->{$method}('table2', $joinExpression);
$rawQuery = $baseRawQuery . $sqlJoin . '"table2" ON ("table1"."joinField" = "table2"."joinField")';
$this->assertEquals($rawQuery, $query->toDialectString($dialect));
$query = $this->getBaseJoinSelect()->{$method}('table2', $joinExpression, 'table2');
$rawQuery = $baseRawQuery . $sqlJoin . '"table2" AS "table2" ' . 'ON ("table1"."joinField" = "table2"."joinField")';
$this->assertEquals($rawQuery, $query->toDialectString($dialect));
}
}
示例9: testQuery
public function testQuery()
{
$query = OSQL::delete()->from('pity_table');
$dialect = ImaginaryDialect::me();
try {
$query->toDialectString($dialect);
$this->fail();
} catch (WrongArgumentException $e) {
/* pass */
}
$query->where(Expression::eq(1, 2));
$this->assertEquals($query->toDialectString($dialect), 'DELETE FROM pity_table WHERE (1 = 2)');
$query->andWhere(Expression::notEq('a', 'b'));
$this->assertEquals($query->toDialectString($dialect), 'DELETE FROM pity_table WHERE (1 = 2) AND (a != b)');
}
示例10: testForgottenDao
public function testForgottenDao()
{
$criteria = Criteria::create()->add(Expression::eq('id', 42));
$listCriteria = clone $criteria;
try {
$listCriteria->getList();
$this->fail();
} catch (WrongStateException $e) {
/*it's good*/
}
$customCriteria = clone $criteria;
try {
$customCriteria->addProjection(Projection::property('id'))->getCustomList();
$this->fail();
} catch (WrongStateException $e) {
/*it's good*/
}
}
示例11: testInnerTransaction
public function testInnerTransaction()
{
foreach (DBTestPool::me()->getPool() as $connector => $db) {
DBPool::me()->setDefault($db);
$this->getDBCreator()->fillDB();
$moscow = TestCity::dao()->getByLogic(Expression::eq('name', 'Moscow'));
$piter = TestCity::dao()->getByLogic(Expression::eq('name', 'Saint-Peterburg'));
$cityNewer = function (TestCity $city) {
$city->dao()->merge($city->setName('New ' . $city->getName()));
};
$citiesNewer = function ($moscow, $piter) use($cityNewer, $db) {
$cityNewer($moscow);
InnerTransactionWrapper::create()->setDB($db)->setFunction($cityNewer)->run($piter);
};
InnerTransactionWrapper::create()->setDao($moscow->dao())->setFunction($citiesNewer)->run($moscow, $piter);
$this->assertNotNull(TestCity::dao()->getByLogic(Expression::eq('name', 'New Moscow')));
$this->assertNotNull(TestCity::dao()->getByLogic(Expression::eq('name', 'New Saint-Peterburg')));
}
}
示例12: sync
/**
* @return OneToManyLinkedFull
**/
public function sync($insert, $update = array(), $delete)
{
$uc = $this->container;
$dao = $uc->getDao();
if ($delete) {
DBPool::getByDao($dao)->queryNull(OSQL::delete()->from($dao->getTable())->where(Expression::eq(new DBField($uc->getParentIdField()), $uc->getParentObject()->getId()))->andWhere(Expression::in($uc->getChildIdField(), ArrayUtils::getIdsArray($delete))));
$dao->uncacheByIds(ArrayUtils::getIdsArray($delete));
}
if ($insert) {
for ($i = 0, $size = count($insert); $i < $size; ++$i) {
$dao->add($insert[$i]);
}
}
if ($update) {
for ($i = 0, $size = count($update); $i < $size; ++$i) {
$dao->save($update[$i]);
}
}
return $this;
}
示例13: testChainForm
public function testChainForm()
{
$form = Form::create()->add(Primitive::string('a'))->add(Primitive::string('b'))->add(Primitive::integer('c'))->add(Primitive::integer('d'))->add(Primitive::boolean('e'))->add(Primitive::string('f'))->import(array('a' => 'true', 'c' => 123, 'd' => 123));
$andChain = Expression::chain()->expAnd(Expression::expOr(new FormField('a'), Expression::notNull(new FormField('b'))))->expAnd(Expression::eq(new FormField('c'), new FormField('d')))->expAnd(Expression::isFalse(new FormField('e')));
$this->assertTrue($andChain->toBoolean($form));
$form->importMore(array('e' => 'on'));
$this->assertFalse($andChain->toBoolean($form));
$orChain = Expression::chain()->expOr(Expression::eq(new FormField('a'), new FormField('b')))->expOr(Expression::expOr(new FormField('e'), Expression::gt(new FormField('c'), new FormField('d'))))->expOr(Expression::in(new FormField('f'), array('qwer', 'asdf', 'zxcv')));
$form->import(array());
$this->assertFalse($orChain->toBoolean($form));
$form->import(array('e' => '1'));
$this->assertTrue($orChain->toBoolean($form));
$form->import(array('a' => 'asdf', 'b' => 'qwerq', 'c' => '13', 'd' => '1313', 'f' => 'iukj'));
$this->assertFalse($orChain->toBoolean($form));
$form->import(array('c' => '13', 'd' => '12'));
$this->assertTrue($orChain->toBoolean($form));
$form->import(array('f' => 'asdfwer'));
$this->assertFalse($orChain->toBoolean($form));
$form->import(array('f' => 'qwer'));
$this->assertTrue($orChain->toBoolean($form));
}
示例14: getById
public function getById($id, $expires = Cache::EXPIRES_MEDIUM)
{
if ($expires !== Cache::DO_NOT_CACHE && ($object = $this->getCachedById($id))) {
if ($object === Cache::NOT_FOUND) {
throw new CachedObjectNotFoundException("there is no such object for '" . $this->dao->getObjectName() . "' with id=" . $id);
}
return $this->dao->completeObject($object);
} else {
$query = $this->dao->makeSelectHead()->andWhere(Expression::eq(DBField::create($this->dao->getIdName(), $this->dao->getTable()), $id));
if ($expires === Cache::DO_NOT_CACHE) {
$object = $this->fetchObject($query);
} else {
$object = $this->cachedFetchObject($query, $expires, true);
}
if ($object) {
return $object;
} else {
throw new ObjectNotFoundException("there is no such object for '" . $this->dao->getObjectName() . "' with query == " . $query->toDialectString(DBPool::me()->getByDao($this->dao)->getDialect()));
}
}
}
示例15: testHaving
public function testHaving()
{
$query = OQL::select('from TestUser');
$criteria = Criteria::create(TestUser::dao());
$this->assertCriteria($query->addHaving(OQL::having('id > 0')), $criteria->addProjection(Projection::having(Expression::gt('id', 0))));
$this->assertCriteria($query->addHaving(OQL::having('name is not null and (id <> $1 or id != $2)')->bindNext(4)->bindNext(8)), $criteria->addProjection(Projection::having(Expression::expAnd(Expression::notNull('name'), Expression::expOr(Expression::notEq('id', 4), Expression::notEq('id', 8))))));
$this->assertEquals(OQL::having('id + $15')->bind(15, 16)->toProjection(), Projection::having(Expression::add('id', 16)));
$this->assertCriteria(OQL::select('from TestUser')->addHaving(OQL::having('id = $1')->bindNext(23))->bindNext(42), Criteria::create(TestUser::dao())->addProjection(Projection::having(Expression::eq('id', 42))));
}