當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Propel::setDB方法代碼示例

本文整理匯總了PHP中Propel::setDB方法的典型用法代碼示例。如果您正苦於以下問題:PHP Propel::setDB方法的具體用法?PHP Propel::setDB怎麽用?PHP Propel::setDB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel的用法示例。


在下文中一共展示了Propel::setDB方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 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());
     }
     Propel::setDB($name, $adapter);
     Propel::setConnection($name, $con, Propel::CONNECTION_READ);
     Propel::setConnection($name, $con, Propel::CONNECTION_WRITE);
     return $con;
 }
開發者ID:halfer,項目名稱:Meshing,代碼行數:21,代碼來源:PropelQuickBuilder.php

示例2: tearDown

 protected function tearDown()
 {
     Propel::setDB(null, $this->savedAdapter);
     parent::tearDown();
 }
開發者ID:ketheriel,項目名稱:ETVA,代碼行數:5,代碼來源:JoinTest.php

示例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);
 }
開發者ID:pkdevbox,項目名稱:mootools-forge,代碼行數:14,代碼來源:CriteriaTest.php

示例4: getMockPropelConnection

 /**
  * @return \PropelPDO
  */
 protected function getMockPropelConnection()
 {
     if (!class_exists('Lexik\\Bundle\\TranslationBundle\\Propel\\om\\BaseFile')) {
         // classes are built in-memory.
         $builder = new \PropelQuickBuilder();
         $builder->setSchema(file_get_contents(__DIR__ . '/../../Resources/config/propel/schema.xml'));
         $builder->setClassTargets(array('tablemap', 'peer', 'object', 'query'));
         $con = $builder->build();
     } else {
         // in memory-classes already exist, create connection and SQL manually
         $dsn = 'sqlite::memory:';
         $adapter = new \DBSQLite();
         $con = new \PropelPDO($dsn, null, null);
         $con->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
         $name = 'default';
         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);
         // don't rebuild classes
         $builder = new \PropelQuickBuilder();
         $builder->setSchema(file_get_contents(__DIR__ . '/../../Resources/config/propel/schema.xml'));
         $builder->buildSQL($con);
     }
     return $con;
 }
開發者ID:cwd,項目名稱:LexikTranslationBundle,代碼行數:31,代碼來源:BaseUnitTestCase.php

示例5: testCriterionIgnoreCase

 /**
  * Test Criterion.setIgnoreCase().
  * As the output is db specific the test just prints the result to
  * System.out
  */
 public function testCriterionIgnoreCase()
 {
     $adapters = array(new DBMySQL(), new DBPostgres());
     $expectedIgnore = array("UPPER(TABLE.COLUMN) LIKE UPPER(:p1)", "TABLE.COLUMN ILIKE :p1");
     $i = 0;
     foreach ($adapters as $adapter) {
         Propel::setDB(null, $adapter);
         $myCriteria = new Criteria();
         $myCriterion = $myCriteria->getNewCriterion("TABLE.COLUMN", "FoObAr", Criteria::LIKE);
         $sb = "";
         $params = array();
         $myCriterion->appendPsTo($sb, $params);
         $expected = "TABLE.COLUMN LIKE :p1";
         $this->assertEquals($expected, $sb);
         $ignoreCriterion = $myCriterion->setIgnoreCase(true);
         $sb = "";
         $params = array();
         $ignoreCriterion->appendPsTo($sb, $params);
         // $expected = "UPPER(TABLE.COLUMN) LIKE UPPER(?)";
         $this->assertEquals($expectedIgnore[$i], $sb);
         $i++;
     }
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:28,代碼來源:CriteriaTest.php

示例6: testOrderByIgnoreCaseWithWhereClause

 public function testOrderByIgnoreCaseWithWhereClause()
 {
     $originalDB = Propel::getDB();
     Propel::setDB(null, new DBMySQL());
     $criteria = new Criteria();
     $criteria->setIgnoreCase(true);
     $criteria->addAscendingOrderByColumn(BookPeer::TITLE);
     $criteria->add('book.title', false);
     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` WHERE UPPER(book.title)=UPPER(:p1) ORDER BY UPPER(book.title) ASC';
     $this->assertEquals($expectedSQL, $sql);
     Propel::setDB(null, $originalDB);
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:15,代碼來源:CriteriaTest.php


注:本文中的Propel::setDB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。