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


PHP Doctrine_Query::select方法代码示例

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


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

示例1: __construct

 /**
  * Constructs Neo_Doctrine_Paginator_Adapter
  *
  * @param Doctrine_Query_Abstract|string $query
  * @param integer $hydratationMode Use constaints Doctrine_Core::HYDRATE_*.
  * @param array[string]=>mixed $options Options may be:
  *              'countQuery'-custom query for count counting. Dql or Doctrine_Query instance.
  */
 public function __construct($query, $hydrationMode = null, $options = array())
 {
     if (is_string($query)) {
         $newQuery = new Doctrine_Query();
         $newQuery->parseDqlQuery($query);
         $query = $newQuery;
     } else {
         if (!$query instanceof Doctrine_Query_Abstract) {
             require_once 'Neo/Doctrine/Paginator/Adapter/Exception.php';
             throw new Neo_Doctrine_Paginator_Adapter_Exception("Given query is not instance of Doctrine_Query");
         }
     }
     $this->_query = $query;
     $this->_hydrationMode = is_null($hydrationMode) ? Doctrine_Core::HYDRATE_RECORD : $hydrationMode;
     //options
     if (!empty($options['countQuery'])) {
         if (is_string($options['countQuery'])) {
             $countQuery = new Doctrine_Query();
             $countQuery->parseDqlQuery($options['countQuery']);
             $options['countQuery'] = $countQuery;
         } else {
             if (!$options['countQuery'] instanceof Doctrine_Query) {
                 require_once 'Neo/Doctrine/Paginator/Adapter/Exception.php';
                 throw new Neo_Doctrine_Paginator_Adapter_Exception("Given count-query is not instance of Doctrine_Query");
             }
         }
         $this->_countQuery = $options['countQuery'];
         $this->_countQuery->select('count(*) as count');
     }
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:38,代码来源:Adapter.php

示例2: executeRemove

 public function executeRemove()
 {
     $id = $this->getRequestParameter('id');
     if ($id) {
         $q = new Doctrine_Query();
         if ($this->getUser()->hasCredential('admin')) {
             $this->comment = $q->select('c.*')->from('Comment c')->where('id = ?', array($id))->execute()->getFirst();
         } else {
             $this->comment = $q->select('c.*')->from('Comment c')->where('id = ? and user_id = ?', array($id, $this->getUser()->getId()))->execute()->getFirst();
         }
         $this->forward404Unless($this->comment);
         $this->comment->delete();
     }
     return $this->redirect($this->getRequest()->getReferer());
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:15,代码来源:actions.class.php

示例3: retrieveAsso

 public function retrieveAsso(Doctrine_Query $q)
 {
     $alias = $q->getRootAlias();
     $q->select("{$alias}.name, {$alias}.login, {$alias}.description, {$alias}.logo, {$alias}.salle, {$alias}.phone, {$alias}.facebook, p.id, p.asso_id, p.couleur");
     $q->leftJoin("{$alias}.Pole p");
     return $q->fetchOne();
 }
开发者ID:TheoJD,项目名称:portail,代码行数:7,代码来源:AssoTable.class.php

示例4: testShortAliasesWithSingleComponent

 /**
 public function testShortAliasesWithSingleComponent() {
     $q = new Doctrine_Query();
 
     $q->select('u.name')->from('User u');
 
     $this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0)');
 }
 */
 public function testShortAliasesWithOneToManyLeftJoin()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, p.id')->from('User u LEFT JOIN u.Phonenumber p');
     $this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id, e.name AS e__name, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)');
     $users = $q->execute();
     $this->assertEqual($users->count(), 8);
 }
开发者ID:swk,项目名称:bluebox,代码行数:17,代码来源:ShortAliasesTestCase.php

示例5: executeShowcase

 public function executeShowcase()
 {
     $q = new Doctrine_Query();
     $this->madule = $q->select('m.*')->from('Madule m')->where('id = ?', array($this->getRequestParameter('id')))->fetchOne();
     $this->forward404Unless($this->madule);
     $this->madule->setShowcase(!$this->madule->getShowcase());
     $this->madule->save();
     return $this->redirect($this->getRequest()->getReferer());
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:9,代码来源:actions.class.php

示例6: 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

示例7: testHydratation

 public function testHydratation()
 {
     $q = new Doctrine_Query();
     $q->select('t.name')->from('NewTag t INDEXBY t.name');
     try {
         $results = $q->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:10,代码来源:1991TestCase.php

示例8: testFetchArraySupportsTwoAggregatesInRelationAndRoot

 public function testFetchArraySupportsTwoAggregatesInRelationAndRoot()
 {
     $q = new Doctrine_Query();
     $q->select("u.*, p.*, CONCAT(u.name, '_1') concat1, CONCAT(u.name, '_2') concat2, CONCAT(p.phonenumber, '_3') concat3, CONCAT(p.phonenumber, '_3') concat4")->from('User u')->innerJoin('u.Phonenumber p')->where("u.name = 'zYne'");
     $users = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
     $this->assertEqual($users[0]['concat1'], 'zYne_1');
     $this->assertEqual($users[0]['concat2'], 'zYne_2');
     $this->assertEqual($users[0]['Phonenumber'][0]['concat3'], '123 123_3');
     $this->assertTrue(isset($users[0]['Phonenumber'][0]['concat4']));
 }
开发者ID:swk,项目名称:bluebox,代码行数:10,代码来源:1461TestCase.php

示例9: testTicket

 public function testTicket()
 {
     try {
         $q = new Doctrine_Query();
         $result = $q->select('d.*')->from('T923_Diagnostic d')->where('d.diag_timestamp >= ? AND d.diag_timestamp <= ?', array('2008-03-27 00:00:00', '2008-03-27 23:00:00'))->addWhere('d.id_type = ?', array('101'))->orderBy('d.diag_timestamp')->limit(20)->offset(0)->execute();
         $this->assertEqual($result->count(), 3);
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:10,代码来源:923TestCase.php

示例10: 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

示例11: testDoctrineQueryJoinSelect

 public function testDoctrineQueryJoinSelect()
 {
     $q = new Doctrine_Query();
     $q->select('person.id, points.total')->from('T1015_Person person')->innerJoin('person.T1015_Points points WITH person.id = 1');
     $results = $q->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     //var_dump($results);
     $person = $results[0];
     // number of points for person id of 1 should be 15
     $this->assertEqual(15, $person['T1015_Points']['total']);
     //THIS WILL FAIL
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:11,代码来源:1015TestCase.php

示例12: testMultipleJoinFetchingWithArrayFetching

 public function testMultipleJoinFetchingWithArrayFetching()
 {
     $query = new Doctrine_Query($this->connection);
     $queryCount = $this->connection->count();
     try {
         $categories = $query->select('c.*, subCats.*, b.*, le.*, a.*')->from('QueryTest_Category c')->leftJoin('c.subCategories subCats')->leftJoin('c.boards b')->leftJoin('b.lastEntry le')->leftJoin('le.author a')->where('c.parentCategoryId = 0')->orderBy('c.position ASC, subCats.position ASC, b.position ASC')->execute(array(), Doctrine::HYDRATE_ARRAY);
         $this->pass();
     } catch (Doctrine_Exception $e) {
         $this->fail($e->getMessage());
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:11,代码来源:MultiJoin2TestCase.php

示例13: testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns

 public function testGetLimitSubqueryWithOrderByOnAggregateValuesAndColumns()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(DISTINCT a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums, u.name');
     $q->groupby('u.id');
     $q->limit(5);
     $q->execute();
     $this->assertEqual($this->dbh->pop(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(DISTINCT a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.id IN (SELECT doctrine_subquery_alias.id FROM (SELECT DISTINCT e2.id, COUNT(DISTINCT a2.id) AS a2__0 FROM entity e2 LEFT JOIN album a2 ON e2.id = a2.user_id WHERE (e2.type = 0) GROUP BY e2.id ORDER BY a2__0, e2.name LIMIT 5) AS doctrine_subquery_alias) AND (e.type = 0) GROUP BY e.id ORDER BY a__0, e.name');
 }
开发者ID:ninjapenguin,项目名称:kohana-Doctrine-module,代码行数:11,代码来源:PgsqlSubqueryTestCase.php

示例14: testTicket

 public function testTicket()
 {
     try {
         $q = new Doctrine_Query();
         $q->update('EnumUpdateBug')->set('bla_id', '?', 5)->set('separator', '?', 'pipe')->where('id = 1')->execute();
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
     $q = new Doctrine_Query();
     $row = $q->select('a.*')->from('EnumUpdateBug a')->where('a.id = 1')->fetchOne();
     $this->assertEqual($row->bla_id, 5);
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:12,代码来源:935TestCase.php

示例15: prepareUpdate

 public function prepareUpdate()
 {
     $id = $this->getRequestParameter('id');
     if ($id) {
         $q = new Doctrine_Query();
         $this->themeGroup = $q->select('t.*')->from('ThemeGroup t')->where('id = ?', array($id))->execute()->getFirst();
         $this->forward404Unless($this->themeGroup);
     } else {
         $this->themeGroup = new ThemeGroup();
     }
     $this->form = new ThemeGroupForm(array('title' => $this->themeGroup->getTitle(), 'known' => $this->themeGroup->getKnown()));
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:12,代码来源:actions.class.php


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