当前位置: 首页>>代码示例>>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;未经允许,请勿转载。