本文整理匯總了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.");
}