本文整理汇总了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));
}
}
示例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.");
}