本文整理汇总了PHP中DBG::getMode方法的典型用法代码示例。如果您正苦于以下问题:PHP DBG::getMode方法的具体用法?PHP DBG::getMode怎么用?PHP DBG::getMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBG
的用法示例。
在下文中一共展示了DBG::getMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startQuery
/**
* {@inheritdoc}
*/
public function startQuery($sql, array $params = null, array $types = null)
{
$this->query = null;
if (!(\DBG::getMode() & DBG_DOCTRINE) && !(\DBG::getMode() & DBG_DOCTRINE_CHANGE) && !(\DBG::getMode() & DBG_DOCTRINE_ERROR)) {
return;
}
// prepare SQL statement
if ($params) {
$sql = str_replace('?', "'%s'", $sql);
//$this->query = vsprintf($sql, $params);
foreach ($params as &$param) {
// serialize arrays
if (is_array($param)) {
$param = serialize($param);
} elseif (is_object($param)) {
// serialize objects
switch (get_class($param)) {
case 'DateTime':
// output DateTime object as date literal
$param = $param->format(ASCMS_DATE_FORMAT_DATETIME);
break;
default:
break;
}
}
}
$sql = vsprintf($sql, $params);
}
\DBG::logSQL($sql);
$this->startTime = microtime(true);
}
示例2: __construct
public function __construct()
{
if (\DBG::getMode() & DBG_ADODB_TRACE) {
\DBG::enable_adodb_debug(true);
} elseif (\DBG::getMode() & DBG_ADODB || \DBG::getMode() & DBG_ADODB_ERROR) {
\DBG::enable_adodb_debug();
} else {
\DBG::disable_adodb_debug();
}
self::$em = \Env::get('em');
self::$defaultLang = \FWLanguage::getDefaultLangId();
$this->initModuleNames();
}
示例3: execute
protected function execute()
{
switch ($this->mode) {
case self::MODE_DQL:
$this->result = '';
$strQuery = trim($this->code);
$lister = new \Cx\Core_Modules\Listing\Controller\ListingController(function (&$offset, &$count, &$criteria, &$order) use($strQuery) {
return \Env::get('em')->createQuery($strQuery);
});
try {
$table = new \BackendTable($lister->getData());
$this->result = $table->toHtml() . $lister;
} catch (\Exception $e) {
$this->result = 'Could not execute query (' . $e->getMessage() . ')!';
}
break;
case self::MODE_PHP:
$dbgMode = \DBG::getMode();
try {
// This error handler catches all Warnings and Notices and some Strict errors
\DBG::activate(DBG_PHP);
set_error_handler(array($this, 'phpErrorsAsExceptionsHandler'));
$this->errrorHandlerActive = true;
// Since DBG catches the rest (E_PARSE) let's use that
ob_start();
$function = create_function('$em, $cx', '' . $this->code . ';');
$dbgContents = ob_get_clean();
\DBG::activate($dbgMode);
if (!is_callable($function)) {
// parse exception
throw new SandboxException($dbgContents);
}
$this->result = var_export($function(\Env::get('em'), \Env::get('cx')), true);
restore_error_handler();
$this->errrorHandlerActive = false;
} catch (\Exception $e) {
\DBG::activate($dbgMode);
restore_error_handler();
$this->errrorHandlerActive = false;
$this->result = get_class($e) . ': ' . $e->getMessage();
}
break;
default:
break;
}
}
示例4: getActivatedFlagsAsString
public static function getActivatedFlagsAsString()
{
$constants = get_defined_constants(true);
$userConstants = array_keys($constants['user']);
$flags = array_filter($userConstants, function ($constant) {
return strpos($constant, 'DBG_') === 0 && constant($constant) && (\DBG::getMode() & constant($constant)) === constant($constant);
});
return join(' | ', $flags);
}
示例5: restoreDebuggingParams
/**
* Expands debugging behaviour with behaviour stored in session if specified and active.
*
* @access private
*/
private function restoreDebuggingParams()
{
if (isset($_SESSION['debugging']) && $_SESSION['debugging']) {
DBG::activate(DBG::getMode() | $_SESSION['debugging_flags']);
}
}
示例6: restoreDebuggingParams
/**
* Expands debugging behaviour with behaviour stored in session if specified and active.
*
* @access protected
*/
protected function restoreDebuggingParams()
{
if (isset($this['debugging']) && $this['debugging']) {
\DBG::activate(\DBG::getMode() | $this['debugging_flags']);
}
}