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


PHP Connection::setDatabaseReflection方法代碼示例

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


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

示例1: createConnection

 /**
  * @return Nette\Database\Connection
  * @throws Nette\InvalidArgumentException
  */
 private function createConnection($name)
 {
     if (empty($this->configs[$name])) {
         throw new Nette\InvalidArgumentException("Connection '{$name}' definition is missing in config!");
     }
     $config = $this->configs[$name];
     $connection = new Nette\Database\Connection($config["dsn"], $config["user"], $config["password"]);
     $connection->setCacheStorage($this->cacheStorage);
     $connection->setDatabaseReflection($this->databaseReflection);
     // Panels are not rendered on production but they are still logging!
     // Preventing them from log in production will decrease memory usage!
     if (!$this->isProduction) {
         $connectionPanel = new Nette\Database\Diagnostics\ConnectionPanel();
         Nette\Diagnostics\Debugger::$bar->addPanel($connectionPanel);
         $connection->onQuery[] = $connectionPanel->logQuery;
     }
     return $connection;
 }
開發者ID:RiKap,項目名稱:ErrorMonitoring,代碼行數:22,代碼來源:ConnectionPool.php

示例2: Connection

<?php

use Nette\Caching\Storages\FileStorage;
use Nette\Database\Connection;
use Nette\Database\Reflection\DiscoveredReflection;
use Nette\Framework;
require_once __DIR__ . '/../../bootstrap.php';
Bootstrap::init();
Bootstrap::check(__DIR__);
$connection = new Connection(Bootstrap::$config['db']['driver'] . ':dbname=' . Bootstrap::$config['db']['dbname'], Bootstrap::$config['db']['user'], Bootstrap::$config['db']['password']);
$cacheStorage = Bootstrap::$config['cache'] ? new FileStorage(__DIR__ . '/temp') : NULL;
$connection->setCacheStorage($cacheStorage);
$connection->setDatabaseReflection(new DiscoveredReflection($cacheStorage));
$dao = $connection;
$startTime = -microtime(TRUE);
ob_start();
foreach ($dao->table('employees')->limit(Bootstrap::$config['limit']) as $employe) {
    echo "{$employe->first_name} {$employe->last_name} ({$employe->emp_no})\n";
    echo "Salaries:\n";
    foreach ($employe->related('salaries') as $salary) {
        echo $salary->salary, "\n";
    }
    echo "Departments:\n";
    foreach ($employe->related('dept_emp') as $department) {
        echo $department->dept->dept_name, "\n";
    }
}
ob_end_clean();
$endTime = microtime(TRUE);
Bootstrap::result('NetteDatabase', '~2.0.0', $startTime, $endTime);
開發者ID:f3l1x,項目名稱:dbals-benchmark,代碼行數:30,代碼來源:run-employees.php


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