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


PHP Doctrine_Query::execute方法代码示例

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


在下文中一共展示了Doctrine_Query::execute方法的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: getItems

 /**
  * Get items
  *
  * @param int $offset
  * @param int $itemsPerPage
  * @return Doctrine_Collection
  */
 public function getItems($offset, $itemsPerPage)
 {
     if ($itemsPerPage !== null) {
         $this->_query->limit($itemsPerPage);
     }
     if ($offset !== null) {
         $this->_query->offset($offset);
     }
     return $this->_query->execute();
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:17,代码来源:DoctrineQuery.php

示例3: testInlineSite

    public function testInlineSite()
    {
        $yml = <<<END
---
Ticket_Product: 
  Product_1: 
    name: book
    Site:
      name: test
END;
        try {
            file_put_contents('test.yml', $yml);
            Doctrine_Core::loadData('test.yml', true);
            $this->conn->clear();
            $query = new Doctrine_Query();
            $query->from('Ticket_Product p, p.Site s')->where('p.name = ?', 'book');
            $product = $query->execute()->getFirst();
            $this->assertEqual($product->name, 'book');
            $this->assertEqual(is_object($product->Site), true);
            $this->assertEqual($product->Site->name, 'test');
            $this->pass();
        } catch (Exception $e) {
            //echo $e->getMessage();
            $this->fail();
        }
        unlink('test.yml');
    }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:27,代码来源:DC23bTestCase.php

示例4: getItems

 /**
  * Implementation of method from Zend_Paginator_Adapter_Interface.
  *
  * @param integer $offset
  * @param integer $itemsPerPage
  * @return array[numeric|whatever]=>array|Doctrine_Record
  */
 public function getItems($offset, $itemsPerPage)
 {
     $this->_query->limit($itemsPerPage);
     $this->_query->offset($offset);
     $result = $this->_query->execute(array(), $this->_hydrationMode);
     return $result;
 }
开发者ID:Neozeratul,项目名称:Intermodels,代码行数:14,代码来源:Adapter.php

示例5: testQuerySupportsIdentifierQuotingInWherePart

 public function testQuerySupportsIdentifierQuotingInWherePart()
 {
     $q = new Doctrine_Query();
     $q->parseDqlQuery('SELECT u.name FROM User u WHERE u.id = 3');
     $this->assertEqual($q->getSqlQuery(), 'SELECT "e"."id" AS "e__id", "e"."name" AS "e__name" FROM "entity" "e" WHERE ("e"."id" = 3 AND ("e"."type" = 0))');
     $q->execute();
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:7,代码来源:IdentifierQuotingTestCase.php

示例6: testZeroValuesMaintained3

 public function testZeroValuesMaintained3()
 {
     $q = new Doctrine_Query();
     $q->from('ZeroValueTest');
     $users = $q->execute();
     $this->assertIdentical($users[0]['is_super_admin'], false);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:7,代码来源:ZeroValuesTestCase.php

示例7: testDiffForOneToManyRelatedCollection

    public function testDiffForOneToManyRelatedCollection()
    {
        $q = new Doctrine_Query();
        $q->from('User u LEFT JOIN u.Phonenumber p')
             ->where('u.id = 8');

        $coll = $q->execute();

        $this->assertEqual($coll->count(), 1);

        $this->assertEqual($coll[0]->Phonenumber->count(), 3);
        $this->assertTrue($coll[0]->Phonenumber instanceof Doctrine_Collection);

        unset($coll[0]->Phonenumber[0]);
        $coll[0]->Phonenumber->remove(2);

        $this->assertEqual(count($coll[0]->Phonenumber->getSnapshot()), 3);
        $coll[0]->save();

        $this->assertEqual($coll[0]->Phonenumber->count(), 1);

        $this->connection->clear();

        $q = new Doctrine_Query();
        $q = Doctrine_Query::create()->from('User u LEFT JOIN u.Phonenumber p')->where('u.id = 8');

        $coll = $q->execute();

        $this->assertEqual($coll[0]->Phonenumber->count(), 1);

    }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:31,代码来源:SnapshotTestCase.php

示例8: execute

 public function execute($params = array(), $hydrationMode = null)
 {
     $breadcrumb = $this->getBreadcrumb();
     $result = parent::execute($params, $hydrationMode);
     $this->restoreBreadcrumb($breadcrumb);
     return $result;
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:7,代码来源:Query.php

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

示例10: format_query_radix

 /**
  * Format the value returned from rec_query() into an array radix.
  *
  * @param Doctrine_Query $q
  * @return array $radix
  */
 protected function format_query_radix(Doctrine_Query $q)
 {
     $recs = $q->execute();
     $radix = array();
     foreach ($recs as $rec) {
         $radix[] = $this->format_radix($rec);
     }
     return $radix;
 }
开发者ID:kaakshay,项目名称:audience-insight-repository,代码行数:15,代码来源:DOCframe_Resource.php

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

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

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

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

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


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