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


PHP Doctrine_Query::from方法代码示例

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


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

示例1: testCreateView

 public function testCreateView()
 {
     $query = new Doctrine_Query($this->connection);
     $query->from('User');
     $view = new Doctrine_View($query, 'MyView');
     $this->assertEqual($view->getName(), 'MyView');
     $this->assertTrue($view->getQuery() === $query);
     $this->assertTrue($view === $query->getView());
     $this->assertTrue($view->getConnection() instanceof Doctrine_Connection);
     $success = true;
     try {
         $view->create();
     } catch (Exception $e) {
         $success = false;
     }
     $this->assertTrue($success);
     $users = $view->execute();
     $count = $this->conn->count();
     $this->assertTrue($users instanceof Doctrine_Collection);
     $this->assertEqual($users->count(), 8);
     $this->assertEqual($users[0]->name, 'zYne');
     $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
     $this->assertEqual($count, $this->conn->count());
     $success = true;
     try {
         $view->drop();
     } catch (Exception $e) {
         $success = false;
     }
     $this->assertTrue($success);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:31,代码来源:ViewTestCase.php

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

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

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

示例5: testQuerySetOffsetToZero

 public function testQuerySetOffsetToZero()
 {
     $q = new Doctrine_Query();
     $q->from('User u');
     $q->offset(20);
     $q->offset(0);
     $this->assertEqual($q->getSqlQuery(), 'SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE (e.type = 0)');
 }
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:8,代码来源:RemoveQueryPartTestCase.php

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

示例7: testMultipleLeftJoin2

    public function testMultipleLeftJoin2() 
    {
        $q = new Doctrine_Query();

        $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');

        $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id, e2.id AS e2__id, e2.name AS e2__name, e2.loginname AS e2__loginname, e2.password AS e2__password, e2.type AS e2__type, e2.created AS e2__created, e2.updated AS e2__updated, e2.email_id AS e2__email_id, p.id AS p__id, p.phonenumber AS p__phonenumber, p.entity_id AS p__entity_id FROM entity e LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id AND e2.type = 1 LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0)");
    }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:8,代码来源:FromTestCase.php

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

示例9: testTicket

 public function testTicket()
 {
     try {
         $q = new Doctrine_Query();
         $r = $q->from('T929_Person P')->leftJoin('P.Country Ct')->leftJoin('Ct.Translation T1 WITH T1.lang = ?', 'fr')->leftJoin('P.JobPositions J')->leftJoin('J.Category C')->leftJoin('C.Translation T2 WITH T2.lang = ?', 'fr')->where('P.name = ?', 'Jonathan')->fetchOne();
     } catch (Exception $e) {
         $this->fail($e->getMessage());
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:9,代码来源:929TestCase.php

示例10: testSubclassReturnedIfInheritanceMatches

 public function testSubclassReturnedIfInheritanceMatches()
 {
     $q = new Doctrine_Query();
     $group = $q->from('Entity')->where('id=?')->execute(array(1))->getFirst();
     $this->assertTrue($group instanceof Group);
     $q = new Doctrine_Query();
     $user = $q->from('Entity')->where('id=?')->execute(array(5))->getFirst();
     $this->assertTrue($user instanceof User);
 }
开发者ID:swk,项目名称:bluebox,代码行数:9,代码来源:ColumnAggregationInheritanceTestCase.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: 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

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

 public function testGetLimitSubqueryWithHavingOnAggregateValuesIncorrectAlias()
 {
     $q = new Doctrine_Query();
     $q->select('u.name, COUNT(a.id) num_albums');
     $q->from('User u, u.Album a');
     $q->orderby('num_albums DESC');
     $q->having('num_albums > 0');
     $q->groupby('u.id');
     $q->limit(5);
     $q->execute();
     $this->dbh->pop();
     $this->assertEqual($this->dbh->pop(), 'SELECT DISTINCT e2.id, COUNT(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 HAVING a2__0 > 0 ORDER BY a2__0 DESC LIMIT 5');
 }
开发者ID:swk,项目名称:bluebox,代码行数:13,代码来源:MysqlSubqueryHavingTestCase.php

示例15: testTicket

 /**
  * Test the existence expected indexes
  */
 public function testTicket()
 {
     $q = new Doctrine_Query();
     // simple query with 1 column selected
     $cAuthors = $q->select('book_id')->from('Author')->groupBy('book_id')->where('book_id = 2')->execute();
     // simple query, with 1 join and all columns selected
     $cAuthors = $q->from('Author, Author.Book')->execute();
     foreach ($cAuthors as $oAuthor) {
         if (!$oAuthor->name) {
             $this->fail('Querying the same table multiple times triggers hydration/caching(?) bug');
         }
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:16,代码来源:574TestCase.php


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