本文整理汇总了PHP中Doctrine_Core::debug方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Core::debug方法的具体用法?PHP Doctrine_Core::debug怎么用?PHP Doctrine_Core::debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Core
的用法示例。
在下文中一共展示了Doctrine_Core::debug方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doctrineInit
/**
* Inialise a Doctrine 1 connection.
*
* Listens for 'doctrine.init_connection' events.
*
* Event arguments are:
* boolean 'lazy' - lazy connect.
* string 'name' - connection name.
*
* @param Zikula_Event $event Event.
*
* @return void
*/
public function doctrineInit(Zikula_Event $event)
{
if (!$this->doctrineManager) {
Doctrine_Core::debug(System::isDevelopmentMode());
$this->doctrineManager = Doctrine_Manager::getInstance();
$internalEvent = new Zikula_Event('doctrine.configure', $this->doctrineManager);
$this->eventManager->notify($internalEvent);
$internalEvent = new Zikula_Event('doctrine.cache', $this->doctrineManager);
$this->eventManager->notify($internalEvent);
}
$lazyConnect = isset($event['lazy']) ? $event['lazy'] : false;
$name = isset($event['name']) ? $event['name'] : 'default';
$connectionInfo = $this->serviceManager['databases'][$name];
// test the DB connection works or just set lazy
try {
if ($lazyConnect) {
$dsn = "{$connectionInfo['dbdriver']}://{$connectionInfo['user']}:{$connectionInfo['password']}@{$connectionInfo['host']}/{$connectionInfo['dbname']}";
$connection = Doctrine_Manager::connection($dsn, $name);
} else {
$dbh = new PDO("{$connectionInfo['dbdriver']}:host={$connectionInfo['host']};dbname={$connectionInfo['dbname']}", $connectionInfo['user'], $connectionInfo['password']);
$connection = Doctrine_Manager::connection($dbh, $name);
$connection->setOption('username', $connectionInfo['user']);
$connection->setOption('password', $connectionInfo['password']);
}
$internalEvent = new Zikula_Event('doctrine.configure', $connection);
$this->eventManager->notify($internalEvent);
} catch (PDOException $e) {
throw new PDOException(__('Connection failed to database') . ': ' . $e->getMessage());
}
// set mysql engine type
if ($connectionInfo['dbdriver'] == 'mysql') {
$connection->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_TYPE, $connectionInfo['dbtabletype']);
}
try {
if (isset($connectionInfo['charset'])) {
$connection->setCharset($connectionInfo['charset']);
}
if (isset($connectionInfo['collate'])) {
$connection->setCollate($connectionInfo['collate']);
}
} catch (Exception $e) {
//if (!System::isInstalling()) {
// throw new Exception(__('Error setting database characterset and collation.'));
//}
}
if ($connectionInfo['dbdriver'] != 'oracle') {
$connection->setAttribute(Doctrine_Core::ATTR_PORTABILITY, Doctrine_Core::PORTABILITY_ALL ^ Doctrine_Core::PORTABILITY_EMPTY_TO_NULL);
}
if (isset($this->serviceManager['log.enabled']) && $this->serviceManager['log.enabled']) {
// add listener that sends events for all sql queries
$connection->setListener(new Zikula_Doctrine_Listener_Profiler());
}
$event->data = $connection;
}
示例2: configureDoctrine
public function configureDoctrine(Doctrine_Manager $manager)
{
Doctrine_Core::debug(sfConfig::get('dm_debug'));
/*
* Configure inheritance
*/
$manager->setAttribute(Doctrine_Core::ATTR_TABLE_CLASS, 'myDoctrineTable');
$manager->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS, 'myDoctrineQuery');
$manager->setAttribute(Doctrine_Core::ATTR_COLLECTION_CLASS, 'myDoctrineCollection');
/*
* Configure charset
*/
$manager->setCharset('utf8');
$manager->setCollate('utf8_unicode_ci');
/*
* Configure hydrators
*/
$manager->registerHydrator('dmFlat', 'Doctrine_Hydrator_dmFlatDriver');
/*
* Configure builder
*/
sfConfig::set('doctrine_model_builder_options', array('generateTableClasses' => true, 'baseClassName' => 'myDoctrineRecord', 'baseTableClassName' => 'myDoctrineTable', 'suffix' => '.class.php'));
}
示例3: formatExceptionMessage
/**
* Formats, and then returns, the message in the specified exception
*
* @param Exception $exception
* @return string
*/
protected function formatExceptionMessage(Exception $exception)
{
$message = $exception->getMessage();
if (Doctrine_Core::debug()) {
$message .= "\n" . $exception->getTraceAsString();
}
return $this->getFormatter()->format($message, 'ERROR') . "\n";
}
示例4: define
* obtain it through the world-wide-web, please send an email
* to blipoteka@gmail.com so we can send you a copy immediately.
*
* @category Blipoteka
* @package Blipoteka_Scripts
* @copyright Copyright (c) 2010-2011 Jakub Argasiński (argasek@gmail.com)
* @license http://blipoteka.pl/license Simplified BSD License
*/
if (!defined('APPLICATION_DOCTRINE_SCRIPT')) {
echo "This script should not be executed directly.\n";
exit(0);
}
define('APPLICATION_ENV', getenv('APPLICATION_ENV') ?: 'cli');
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
include __DIR__ . DS . '..' . DS . 'public' . DS . 'initenv.php';
$bootstrap = $application->bootstrap('doctrine')->getBootstrap();
$doctrine = $bootstrap->getResource('doctrine');
Doctrine_Core::debug(true);
// PEAR style loading -- prevents Doctrine's premature ejaculation
$doctrineManager = $doctrine->getManager();
$doctrineManager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_PEAR);
$connectionOptions = $doctrineManager->getCurrentConnection()->getOptions();
echo sprintf("Environment: %s, DSN: '%s'\n", APPLICATION_ENV, $connectionOptions['dsn']);