當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Doctrine_Query::fetchOne方法代碼示例

本文整理匯總了PHP中Doctrine_Query::fetchOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Query::fetchOne方法的具體用法?PHP Doctrine_Query::fetchOne怎麽用?PHP Doctrine_Query::fetchOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine_Query的用法示例。


在下文中一共展示了Doctrine_Query::fetchOne方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: fetchOne

 public function fetchOne($params = array(), $hydrationMode = null)
 {
     $breadcrumb = $this->getBreadcrumb();
     $result = parent::fetchOne($params, $hydrationMode);
     $this->restoreBreadcrumb($breadcrumb);
     return $result;
 }
開發者ID:JoshuaEstes,項目名稱:sfDoctrineExtraPlugin,代碼行數:7,代碼來源:Query.php

示例3: testInlineMultiple

    public function testInlineMultiple()
    {
        $yml = <<<END
---
DC147_Multiple:
  ISBN2:
    name: isbn2
  ISBN3:
    name: isbn3
DC147_Product: 
  Product_1: 
    name: book3
    MultipleValues:
      Multi_1:
        value: 123345678
        Multiple: ISBN2
      Multi_2:
        value: 232323233
        Multiple: ISBN3
  Product_2: 
    name: book4
    MultipleValues:
      Multi_3:
        value: 444455555
        Multiple: ISBN2
      Multi_4:
        value: 232323233
        Multiple: ISBN3
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book3');
            $product = $query->fetchOne();
            $this->assertEqual($product->name, 'book3');
            $this->assertEqual($product->MultipleValues->count(), 2);
            $this->assertEqual($product->MultipleValues[0]->value, '123345678');
            $this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
            $this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
            $query = new Doctrine_Query();
            $query->from('DC147_Product p, p.MultipleValues v, v.Multiple m')->where('p.name = ?', 'book4');
            $product = $query->fetchOne();
            $this->assertEqual($product->name, 'book4');
            $this->assertEqual($product->MultipleValues->count(), 2);
            $this->assertEqual($product->MultipleValues[0]->value, '444455555');
            $this->assertEqual($product->MultipleValues[1]->value, '232323233');
            $this->assertEqual(is_object($product->MultipleValues[0]->Multiple), true);
            $this->assertEqual(is_object($product->MultipleValues[1]->Multiple), true);
            $this->assertEqual($product->MultipleValues[0]->Multiple->name, 'isbn2');
            $this->assertEqual($product->MultipleValues[1]->Multiple->name, 'isbn3');
            $this->pass();
        } catch (Exception $e) {
            $this->fail();
        }
        unlink('test.yml');
    }
開發者ID:kaakshay,項目名稱:audience-insight-repository,代碼行數:58,代碼來源:DC147TestCase.php

示例4: testTicket

 public function testTicket()
 {
     Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
     $q = new Doctrine_Query();
     $q->select('s.*')->from('Ticket_1116_User s')->where('s.username = ?', array('test'));
     // to see the error switch dbh to a real db, the next line will trigger the error
     $test = $q->fetchOne();
     //will only fail with "real" mysql
     $this->assertFalse($test);
     $sql = $q->getSqlQuery();
     // just getSql()?!?! and it works ? the params are ok after this call
     $params = $q->getFlattenedParams();
     $this->assertEqual(count($params), 1);
     // now we have array('test',null) very strange .....
     $this->assertEqual($sql, "SELECT u.id AS u__id, u.username AS u__username, u.deleted_at AS u__deleted_at FROM user u WHERE (u.username = ? AND (u.deleted_at IS NULL))");
     $this->assertEqual($params, array('test'));
     //now also this works! (always works witch mock only fails with mysql)
     $test = $q->fetchOne();
     $this->assertFalse($test);
     Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, false);
 }
開發者ID:kaakshay,項目名稱:audience-insight-repository,代碼行數:21,代碼來源:1116TestCase.php

示例5: fetchOne

 public function fetchOne($params = array(), $hydrationMode = null)
 {
     $result = parent::fetchOne($params, $hydrationMode);
     $_p = $this->getParams($params);
     if ('exist' === $_p['where'][0]) {
         $tpl = new myTemplate();
         $tpl->fromArray(array('id' => 1, 'name' => 'exist', 'body' => 'exist', 'renderer' => 'php'));
         return $tpl;
     } elseif ('empty' === $_p['where'][0]) {
         $tpl = new myTemplate();
         $tpl->fromArray(array('id' => 1, 'name' => '', 'body' => '', 'renderer' => 'php'));
         return $tpl;
     }
     return $result;
 }
開發者ID:te-koyama,項目名稱:openpne,代碼行數:15,代碼來源:sfTemplateSwitchableLoaderDoctrineTest.php

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

示例7: routeTest10

 public function routeTest10(Doctrine_Query $q)
 {
     $q->orWhere($q->getRootAlias() . '.is_on_homepage = ?', 0);
     return $q->fetchOne();
 }
開發者ID:seven07ve,項目名稱:vendorepuestos,代碼行數:5,代碼來源:ArticleTable.class.php

示例8: fetchOne

 public function fetchOne($params = array(), $hydrationMode = null)
 {
     $this->limit(1);
     return parent::fetchOne($params, $hydrationMode);
 }
開發者ID:niryuu,項目名稱:OpenPNE3,代碼行數:5,代碼來源:opDoctrineQuery.class.php

示例9: retrieveActiveJob

 public function retrieveActiveJob(Doctrine_Query $q)
 {
     $q->andWhere('a.expires_at > ?', date('Y-m-d H:i:s', time()));
     return $q->fetchOne();
 }
開發者ID:sundesz,項目名稱:crafthouse,代碼行數:5,代碼來源:JobeetJobTable.class.php

示例10: testFetchingCtiRecordsSupportsLimitSubqueryAlgorithm

    public function testFetchingCtiRecordsSupportsLimitSubqueryAlgorithm()
    {
    	$record = new CTITestOneToManyRelated;
    	$record->name = 'Someone';
    	$record->cti_id = 1;
    	$record->save();

        $this->conn->clear();

        $q = new Doctrine_Query();
        $q->from('CTITestOneToManyRelated c')->leftJoin('c.CTITest c2')->where('c.id = 1')->limit(1);

        $record = $q->fetchOne();
        
        $this->assertEqual($record->name, 'Someone');
        $this->assertEqual($record->cti_id, 1);

        $cti = $record->CTITest[0];

        $this->assertEqual($cti->id, 1);
        $this->assertEqual($cti->name, 'Jack Daniels');
        $this->assertEqual($cti->verified, true);
        $this->assertTrue(isset($cti->added));
        $this->assertEqual($cti->age, 13);
    }
開發者ID:prismhdd,項目名稱:victorioussecret,代碼行數:25,代碼來源:ClassTableInheritanceTestCase.php

示例11: retrieveActiveJob

 public function retrieveActiveJob(Doctrine_Query $query)
 {
     $query->addWhere('a.expires_at > ?', date('Y-m-d H:i:s', time() - 86400 * sfConfig::get('app_active_days')));
     return $query->fetchOne();
 }
開發者ID:kalimatas,項目名稱:jobeet,代碼行數:5,代碼來源:JobeetJobTable.class.php

示例12: retrieveForRoute

 public function retrieveForRoute(Doctrine_Query $q)
 {
     $q->leftJoin($q->getRootAlias() . '.Articles');
     return $q->fetchOne();
 }
開發者ID:kbond,項目名稱:zsBlogPlugin,代碼行數:5,代碼來源:PluginzsBlogTagTable.class.php


注:本文中的Doctrine_Query::fetchOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。