当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::setCacheStorage方法代码示例

本文整理汇总了PHP中Nette\Database\Connection::setCacheStorage方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::setCacheStorage方法的具体用法?PHP Connection::setCacheStorage怎么用?PHP Connection::setCacheStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Database\Connection的用法示例。


在下文中一共展示了Connection::setCacheStorage方法的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::setCacheStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。