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


PHP Propel::getDb方法代码示例

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


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

示例1: testExplainPlanFromString

 public function testExplainPlanFromString()
 {
     BookstoreDataPopulator::depopulate($this->con);
     BookstoreDataPopulator::populate($this->con);
     $db = Propel::getDb(BookPeer::DATABASE_NAME);
     $query = 'SELECT book.TITLE AS Title FROM book INNER JOIN author ON (book.AUTHOR_ID=author.ID) WHERE author.FIRST_NAME = \'Neal\'';
     $stmt = $db->doExplainPlan($this->con, $query);
     $explain = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if ($db instanceof DBMySQL) {
         $this->assertEquals(sizeof($explain), 2, 'Explain plan return two lines');
         // explain can change sometime, test can't be strict
         $this->assertArrayHasKey('select_type', $explain[0], 'Line 1, select_type key exist');
         $this->assertArrayHasKey('table', $explain[0], 'Line 1, table key exist');
         $this->assertArrayHasKey('type', $explain[0], 'Line 1, type key exist');
         $this->assertArrayHasKey('possible_keys', $explain[0], 'Line 1, possible_keys key exist');
         $this->assertArrayHasKey('select_type', $explain[1], 'Line 2, select_type key exist');
         $this->assertArrayHasKey('table', $explain[1], 'Line 2, table key exist');
         $this->assertArrayHasKey('type', $explain[1], 'Line 2, type key exist');
         $this->assertArrayHasKey('possible_keys', $explain[1], 'Line 2, possible_keys key exist');
     } elseif ($db instanceof DBOracle) {
         $this->assertTrue(sizeof($explain) > 2, 'Explain plan return more than 2 lines');
     } else {
         $this->markTestSkipped('Cannot test explain plan on adapter ' . get_class($db));
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:25,代码来源:ExplainPlanTest.php

示例2: testDefaultExpresions_ReloadOnInsert_Override

 /**
  * Tests the overriding reloadOnInsert at runtime.
  *
  * @link       http://trac.propelorm.org/ticket/378
  * @link       http://trac.propelorm.org/ticket/555
  */
 public function testDefaultExpresions_ReloadOnInsert_Override()
 {
     if (Propel::getDb(BookstoreEmployeePeer::DATABASE_NAME) instanceof DBSqlite) {
         $this->markTestSkipped("Cannot test default date expressions with SQLite");
     }
     // Create a new bookstore, contest, bookstore_contest, and bookstore_contest_entry
     $b = new Bookstore();
     $b->setStoreName("Barnes & Noble");
     $b->save();
     $c = new Contest();
     $c->setName("Bookathon Contest");
     $c->save();
     $bc = new BookstoreContest();
     $bc->setBookstore($b);
     $bc->setContest($c);
     $bc->save();
     $c = new Customer();
     $c->setName("Happy Customer");
     $c->save();
     $bce = new BookstoreContestEntry();
     $bce->setBookstore($b);
     $bce->setBookstoreContest($bc);
     $bce->setCustomer($c);
     $bce->save(null, $skipReload = true);
     $this->assertNull($bce->getEntryDate(), "Expected a NULL entry_date after save.");
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:32,代码来源:GeneratedObjectTest.php


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