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


PHP Propel::getConfiguration方法代碼示例

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


在下文中一共展示了Propel::getConfiguration方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testDebugLog

 public function testDebugLog()
 {
     $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     $config = Propel::getConfiguration(Registry::TYPE_OBJECT);
     // save data to return to normal state after test
     $logger = $con->getLogger();
     $testLog = new myLogger();
     $con->setLogger($testLog);
     $logEverything = array('exec', 'query', 'beginTransaction', 'commit', 'rollBack', 'statement_execute');
     Propel::getConfiguration(Registry::TYPE_OBJECT)->setParameter("debugpdo.logging.methods", $logEverything, false);
     $con->useDebug(true);
     $con->beginTransaction();
     // test transaction log
     $this->assertEquals('log: Begin transaction', $testLog->latestMessage, 'PropelPDO logs begin transation in debug mode');
     $con->commit();
     $this->assertEquals('log: Commit transaction', $testLog->latestMessage, 'PropelPDO logs commit transation in debug mode');
     $con->beginTransaction();
     $con->rollBack();
     $this->assertEquals('log: Rollback transaction', $testLog->latestMessage, 'PropelPDO logs rollback transation in debug mode');
     $con->beginTransaction();
     $testLog->latestMessage = '';
     $con->beginTransaction();
     $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested begin transation in debug mode');
     $con->commit();
     $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested commit transation in debug mode');
     $con->beginTransaction();
     $con->rollBack();
     $this->assertEquals('', $testLog->latestMessage, 'PropelPDO does not log nested rollback transation in debug mode');
     $con->rollback();
     // test query log
     $con->beginTransaction();
     $c = new Criteria();
     $c->add(BookPeer::TITLE, 'Harry%s', Criteria::LIKE);
     $books = BookPeer::doSelect($c, $con);
     $latestExecutedQuery = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.TITLE LIKE 'Harry%s'";
     $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs queries and populates bound parameters in debug mode');
     BookPeer::doDeleteAll($con);
     $latestExecutedQuery = "DELETE FROM `book`";
     $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs deletion queries in debug mode');
     $latestExecutedQuery = 'DELETE FROM book WHERE 1=1';
     $con->exec($latestExecutedQuery);
     $this->assertEquals('log: ' . $latestExecutedQuery, $testLog->latestMessage, 'PropelPDO logs exec queries in debug mode');
     $con->commit();
     // return to normal state after test
     $con->setLogger($logger);
     $config->setParameter("debugpdo.logging.methods", array('PropelPDO::exec', 'PropelPDO::query', 'DebugPDOStatement::execute'));
 }
開發者ID:norfil,項目名稱:Propel2,代碼行數:47,代碼來源:PropelPDOTest.php

示例2: getConfiguration

 /**
  * Get the runtime configuration
  *
  * @return    PropelConfiguration
  */
 public function getConfiguration()
 {
     if (null === $this->configuration) {
         $this->configuration = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
     }
     return $this->configuration;
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:12,代碼來源:PropelPDO.php


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