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


PHP Doctrine_Query::where方法代码示例

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


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

示例1: execute

 public function execute(&$value, &$error)
 {
     $className = $this->getParameter('class');
     $columnName = $className . '.' . $this->getParameter('column');
     $primaryKeys = sfDoctrine::getTable($className)->getPrimaryKeys();
     foreach ($primaryKeys as $primaryKey) {
         if (is_null($primaryKeyValue = $this->getContext()->getRequest()->getParameter($primaryKey))) {
         }
         break;
     }
     $query = new Doctrine_Query();
     $query->from($className);
     $value = strtolower($value);
     if ($primaryKeyValue === null) {
         $query->where($columnName . ' = ?');
         $res = $query->execute(array($value));
     } else {
         $query->where($columnName . ' = ? AND ' . $primaryKey . ' != ?');
         $res = $query->execute(array($value, $primaryKeyValue));
     }
     if (sizeof($res)) {
         $error = $this->getParameterHolder()->get('unique_error');
         return false;
     }
     return true;
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:26,代码来源:myUniqueValidator.php

示例2: testApplyInheritance

 public function testApplyInheritance()
 {
     $query = new Doctrine_Query();
     $query->from('InheritanceDeal d, d.Users u');
     $query->where('u.id = 1');
     $sql = 'SELECT i.id AS i__id, i.name AS i__name, i2.id AS i2__id, i2.username AS i2__username FROM inheritance_deal i LEFT JOIN inheritance_entity_user i3 ON (i.id = i3.entity_id) AND i3.type = 1 LEFT JOIN inheritance_user i2 ON i2.id = i3.user_id WHERE i2.id = 1';
     $this->assertEqual($sql, $query->getSql());
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:8,代码来源:ApplyInheritanceTestCase.php

示例3: getTypes

 public static function getTypes($public_only = false)
 {
     $q = new Doctrine_Query();
     $q->select('i.*');
     $q->from('GcrInstitutionType i');
     if ($public_only) {
         $q->where('i.is_public = ?', 't');
     }
     return $q->execute();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:10,代码来源:GcrInstitutionTypeTable.class.php

示例4: getEschoolTypes

 public static function getEschoolTypes($public_only = false)
 {
     $q = new Doctrine_Query();
     $q->select('e.*');
     $q->from('GcrEschoolType e');
     if ($public_only) {
         $q->where('e.is_public = ?', 't');
     }
     return $q->execute();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:10,代码来源:GcrEschoolTypeTable.class.php

示例5: testSubqueryExtractionUsesWrongAliases

 public function testSubqueryExtractionUsesWrongAliases()
 {
     $q = new Doctrine_Query();
     $q->from('RelX x');
     $q->leftJoin('x.y xy');
     $q->where('x.created_at IN (SELECT MAX(x2.created_at) latestInCategory FROM RelX x2 WHERE x.category = x2.category)');
     $q->limit(5);
     //echo $sql = $q->getSqlQuery();
     //	echo $sql;
     $xs = $q->execute();
     // Doctrine_Ticket_1254_TestCase : method testSubqueryExtractionUsesWrongAliases failed on line 76
     // This fails sometimes at
     $this->assertEqual(2, count($xs));
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:14,代码来源:1254TestCase.php

示例6: testConditionParser2

 public function testConditionParser2()
 {
     $query = new Doctrine_Query($this->connection);
     $query->select('User.id')->from("User")->where("User.name LIKE 'z%' OR User.name LIKE 's%'");
     $sql = "SELECT e.id AS e__id FROM entity e WHERE (e.name LIKE 'z%' OR e.name LIKE 's%') AND (e.type = 0)";
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("(User.name LIKE 'z%') OR (User.name LIKE 's%')");
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("((User.name LIKE 'z%') OR (User.name LIKE 's%'))");
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("(((User.name LIKE 'z%') OR (User.name LIKE 's%')))");
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("(((User.name LIKE 'z%') OR User.name LIKE 's%'))");
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("(User.name LIKE 'z%') OR User.name LIKE 's%' AND User.name LIKE 'a%'");
     $sql = "SELECT e.id AS e__id FROM entity e WHERE ((e.name LIKE 'z%' OR e.name LIKE 's%') AND e.name LIKE 'a%') AND (e.type = 0)";
     $this->assertEqual($query->getQuery(), "SELECT e.id AS e__id FROM entity e WHERE (e.name LIKE 'z%' OR (e.name LIKE 's%' AND e.name LIKE 'a%')) AND (e.type = 0)");
     $query->where("(((User.name LIKE 'z%') OR User.name LIKE 's%')) AND User.name LIKE 'a%'");
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("((((User.name LIKE 'z%') OR User.name LIKE 's%')) AND User.name LIKE 'a%')");
     $this->assertEqual($query->getQuery(), $sql);
     $query->where("(((((User.name LIKE 'z%') OR User.name LIKE 's%')) AND User.name LIKE 'a%'))");
     $this->assertEqual($query->getQuery(), $sql);
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:24,代码来源:ConditionTestCase.php

示例7: testSubqueryExtractionUsesWrongAliases

    public function testSubqueryExtractionUsesWrongAliases()
    {
        $q = new Doctrine_Query();
        $q->from('RelX x');
    	$q->leftJoin('x.y xy');
    	$q->where('x.created_at IN (SELECT MAX(x2.created_at) latestInCategory FROM RelX x2 WHERE x.category = x2.category)');
    	$q->limit(5);

        //echo $sql = $q->getSql();
        //	echo $sql;

        $xs = $q->execute();
        
        $this->assertEqual(3, count($xs));
        
    }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:16,代码来源:1254TestCase.php

示例8: testMultipleAggregateValuesWithArrayFetching

 public function testMultipleAggregateValuesWithArrayFetching()
 {
     $query = new Doctrine_Query();
     $query->select('u.*, COUNT(DISTINCT b.id) num_books, COUNT(DISTINCT a.id) num_albums');
     $query->from('User u');
     $query->leftJoin('u.Album a, u.Book b');
     $query->where("u.name = 'jon'");
     $query->limit(1);
     $users = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     try {
         $name = $users[0]['name'];
         $num_albums = $users[0]['num_albums'];
         $num_books = $users[0]['num_books'];
     } catch (Doctrine_Exception $e) {
         $this->fail();
     }
     $this->assertEqual($num_albums, 3);
     $this->assertEqual($num_books, 2);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:MultipleAggregateValueTestCase.php

示例9: testBug

 public function testBug()
 {
     $person = $this->newPerson('Fixe');
     $profile = $this->newProfile('Work', $person);
     $guardUser = $person->get('sfGuardUser');
     $id = $guardUser->get('id');
     $guardUser->free();
     $query = new Doctrine_Query();
     $query->select('s.*, p.*, ps.*');
     $query->from('sfGuardUser s');
     $query->innerJoin('s.Person p');
     $query->leftJoin('p.Profiles ps');
     $query->where('s.id = ?', $id);
     $user = $query->fetchOne();
     $array = $user->toArray(true);
     $this->assertEqual($array['id'], 1);
     $this->assertEqual($array['name'], 'Fixe');
     $this->assertTrue(isset($array['Person']['Profiles'][0]));
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:19,代码来源:876TestCase.php

示例10: remove

 public function remove($domain_key, $owner_uid, $target_uid)
 {
     if (!$domain_key || !$owner_uid || !$target_uid) {
         return false;
     }
     $q = new Doctrine_Query();
     $q->select('id');
     $q->from('RingsideFriend');
     $q->where("domain_key='{$domain_key}' and from_id='{$owner_uid}' and to_id='{$target_uid}'");
     $res = $q->execute();
     if (count($res) > 0) {
         $res = $res->toArray();
         $friend_id = $res[0]['id'];
         $row = Doctrine::getTable('RingsideFriend')->find($friend_id);
         if ($row !== false) {
             return $row->delete();
         } else {
             return false;
         }
     }
     return false;
 }
开发者ID:jkinner,项目名称:ringside,代码行数:22,代码来源:BetterFriendsServiceImpl.php

示例11: buildIntegrityRelationQuery

 public function buildIntegrityRelationQuery(Doctrine_Record $record)
 {
     $q = new Doctrine_Query();
     $aliases = array();
     $indexes = array();
     $root = $record->getTable()->getComponentName();
     $rootAlias = strtolower(substr($root, 0, 1));
     $aliases[$rootAlias] = $root;
     foreach ((array) $record->getTable()->getIdentifier() as $id) {
         $field = $rootAlias . '.' . $id;
         $cond[] = $field . ' = ?';
         $fields[] = $field;
         $params = $record->get($id);
     }
     $fields = implode(', ', $fields);
     $components[] = $root;
     $this->buildIntegrityRelations($record->getTable(), $aliases, $fields, $indexes, $components);
     $q->select($fields)->from($root . ' ' . $rootAlias);
     foreach ($aliases as $alias => $name) {
         $q->leftJoin($rootAlias . '.' . $name . ' ' . $alias);
     }
     $q->where(implode(' AND ', $cond));
     return $q->execute(array($params));
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:24,代码来源:IntegrityMapper.php

示例12: testTicket

 public function testTicket()
 {
     $q1 = new Doctrine_Query();
     $q1->select('p.*');
     $q1->from('Testing_Product p');
     $q1->where('p.id = ?', $this->p1['id']);
     $q1->addSelect('a.*, ad.*');
     $q1->leftJoin('p.Attributes a');
     $q1->leftJoin('a.Definition ad');
     $q2 = new Doctrine_Query();
     $q2->select('p.*');
     $q2->from('Testing_Product p');
     $q2->where('p.id = ?', $this->p2['id']);
     $q2->addSelect('a.*, ad.*');
     $q2->leftJoin('p.Attributes a');
     $q2->leftJoin('a.Definition ad');
     // This query works perfect
     $r1 = $q1->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     //var_dump($r1);
     // This query throws an exception!!!
     $r2 = $q2->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     //$r2 = $q2->execute();
     //var_dump($r2);
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:24,代码来源:NewTicketTestCase.php

示例13: insertAsParentOf

 /**
  * inserts node as parent of dest record
  *
  * @return bool
  * @todo Wrap in transaction          
  */
 public function insertAsParentOf(Doctrine_Record $dest)
 {
     // cannot insert a node that has already has a place within the tree
     if ($this->isValidNode()) {
         return false;
     }
     // cannot insert as parent of root
     if ($dest->getNode()->isRoot()) {
         return false;
     }
     // cannot insert as parent of itself
     if ($dest === $this->record || $dest->exists() && $this->record->exists() && $dest->identifier() === $this->record->identifier()) {
         throw new Doctrine_Tree_Exception("Cannot insert node as parent of itself");
         return false;
     }
     $newLeft = $dest->getNode()->getLeftValue();
     $newRight = $dest->getNode()->getRightValue() + 2;
     $newRoot = $dest->getNode()->getRootValue();
     $newLevel = $dest->getNode()->getLevel();
     $conn = $this->record->getTable()->getConnection();
     try {
         $conn->beginInternalTransaction();
         // Make space for new node
         $this->shiftRLValues($dest->getNode()->getRightValue() + 1, 2, $newRoot);
         // Slide child nodes over one and down one to allow new parent to wrap them
         $componentName = $this->_tree->getBaseComponent();
         $q = new Doctrine_Query();
         $q->update($componentName);
         $q->set("{$componentName}.lft", "{$componentName}.lft + 1");
         $q->set("{$componentName}.rgt", "{$componentName}.rgt + 1");
         $q->set("{$componentName}.level", "{$componentName}.level + 1");
         $q->where("{$componentName}.lft >= ? AND {$componentName}.rgt <= ?", array($newLeft, $newRight));
         $q = $this->_tree->returnQueryWithRootId($q, $newRoot);
         $q->execute();
         $this->record['level'] = $newLevel;
         $this->insertNode($newLeft, $newRight, $newRoot);
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw $e;
     }
     return true;
 }
开发者ID:hasanozgan,项目名称:kissabe,代码行数:49,代码来源:NestedSet.php

示例14: addTagsListColumnQuery

 public function addTagsListColumnQuery(Doctrine_Query $query, $field, $values)
 {
     if (!is_array($values)) {
         $values = array($values);
     } else {
         $values = array_keys($values);
     }
     if (!count($values)) {
         return;
     }
     $ids = Doctrine::getTable('tagging')->createQuery()->select('taggable_id')->leftJoin('tagging.Tag tag')->where('taggable_model = ?', $this->getModelName())->andWhereIn('tag.name', $values)->groupBy('taggable_id')->execute(array(), Doctrine::HYDRATE_SCALAR);
     $ids = array_map(create_function('$i', 'return $i["tagging_taggable_id"];'), $ids);
     if (empty($ids)) {
         $query->where('false');
     } else {
         $query->whereIn($query->getRootAlias() . '.id', $ids);
     }
 }
开发者ID:existanze,项目名称:apostropheBlogPlugin,代码行数:18,代码来源:PluginaBlogItemFormFilter.class.php

示例15: insertAsParentOf

 /**
  * inserts node as parent of dest record
  *
  * @return bool
  * @todo Wrap in transaction          
  */
 public function insertAsParentOf(Doctrine_Record $dest)
 {
     // cannot insert a node that has already has a place within the tree
     if ($this->isValidNode()) {
         return false;
     }
     // cannot insert as parent of root
     if ($dest->getNode()->isRoot()) {
         return false;
     }
     $newLeft = $dest->getNode()->getLeftValue();
     $newRight = $dest->getNode()->getRightValue() + 2;
     $newRoot = $dest->getNode()->getRootValue();
     $newLevel = $dest->getNode()->getLevel();
     // Make space for new node
     $this->shiftRLValues($dest->getNode()->getRightValue() + 1, 2, $newRoot);
     // Slide child nodes over one and down one to allow new parent to wrap them
     $componentName = $this->_tree->getBaseComponent();
     $q = new Doctrine_Query();
     $q->update($componentName);
     $q->set("{$componentName}.lft", "{$componentName}.lft + 1");
     $q->set("{$componentName}.rgt", "{$componentName}.rgt + 1");
     $q->set("{$componentName}.level", "{$componentName}.level + 1");
     $q->where("{$componentName}.lft >= ? AND {$componentName}.rgt <= ?", array($newLeft, $newRight));
     $q = $this->_tree->returnQueryWithRootId($q, $newRoot);
     $q->execute();
     $this->record['level'] = $newLevel;
     $this->insertNode($newLeft, $newRight, $newRoot);
     return true;
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:36,代码来源:NestedSet.php


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