本文整理汇总了PHP中Propel\Runtime\Propel::setDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::setDB方法的具体用法?PHP Propel::setDB怎么用?PHP Propel::setDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Runtime\Propel
的用法示例。
在下文中一共展示了Propel::setDB方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build($dsn = null, $user = null, $pass = null, $adapter = null)
{
if (null === $dsn) {
$dsn = 'sqlite::memory:';
}
if (null === $adapter) {
$adapter = new \Propel\Runtime\Adapter\DBSQLite();
}
$con = new PropelPDO($dsn, $user, $pass);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$this->buildSQL($con);
$this->buildClasses();
$name = $this->getDatabase()->getName();
if (!Propel::isInit()) {
Propel::setConfiguration(array('datasources' => array('default' => $name)));
}
Propel::setDB($name, $adapter);
Propel::setConnection($name, $con, Propel::CONNECTION_READ);
Propel::setConnection($name, $con, Propel::CONNECTION_WRITE);
return $con;
}
示例2: tearDown
protected function tearDown()
{
Propel::setDB(null, $this->savedAdapter);
parent::tearDown();
}
示例3: testOrderByIgnoreCase
public function testOrderByIgnoreCase()
{
$originalDB = Propel::getDB();
Propel::setDB(null, new DBMySQL());
$criteria = new Criteria();
$criteria->setIgnoreCase(true);
$criteria->addAscendingOrderByColumn(BookPeer::TITLE);
BookPeer::addSelectColumns($criteria);
$params = array();
$sql = BasePeer::createSelectSql($criteria, $params);
$expectedSQL = 'SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, UPPER(book.TITLE) FROM `book` ORDER BY UPPER(book.TITLE) ASC';
$this->assertEquals($expectedSQL, $sql);
Propel::setDB(null, $originalDB);
}