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


PHP ezcDbInstance::set方法代码示例

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


在下文中一共展示了ezcDbInstance::set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: R3AppInitDB

function R3AppInitDB()
{
    global $mdb2;
    global $dsn;
    require_once 'MDB2.php';
    if (!isset($dsn) || $dsn == '') {
        throw new Exception('Missing $dsn');
    }
    $txtDsn = $dsn['dbtype'] . '://' . $dsn['dbuser'] . ':' . $dsn['dbpass'] . '@' . $dsn['dbhost'] . '/' . $dsn['dbname'];
    $db = ezcDbFactory::create($txtDsn);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    PEAR::setErrorHandling(PEAR_ERROR_EXCEPTION);
    $mdb2 = MDB2::singleton($txtDsn);
    // Needed by user manager and import/export
    ezcDbInstance::set($db);
    if (isset($dsn['charset'])) {
        $db->exec("SET client_encoding TO '{$dsn['charset']}'");
        $mdb2->exec("SET client_encoding TO '{$dsn['charset']}'");
    }
    if (isset($dsn['search_path'])) {
        $db->exec("SET search_path TO {$dsn['search_path']}, public");
        $mdb2->exec("SET search_path TO {$dsn['search_path']}, public");
    }
    $db->exec("SET datestyle TO ISO");
    $mdb2->exec("SET datestyle TO ISO");
}
开发者ID:r3-gis,项目名称:EcoGIS,代码行数:26,代码来源:eco_app.php

示例2: testChooseDefault

 public function testChooseDefault()
 {
     $db = ezcDbInstance::get();
     $db = clone $db;
     $db->a = "something";
     ezcDbInstance::set($db, 'secondary');
     ezcDbInstance::chooseDefault('secondary');
     $this->assertEquals(true, isset(ezcDbInstance::get()->a));
 }
开发者ID:oandre,项目名称:database,代码行数:9,代码来源:instance_test.php

示例3: spl_autoload_register

<?php

require_once 'ezc/Base/base.php';
spl_autoload_register(array('ezcBase', 'autoload'));
ezcBase::addClassRepository('./lib', './lib/autoload');
$options = new ezcBaseAutoloadOptions();
$options->debug = true;
ezcBase::setOptions($options);
$rootdir = dirname(__FILE__);
$db = ezcDbFactory::create("sqlite://{$rootdir}/tmp/mergequeue.db");
ezcDbInstance::set($db);
开发者ID:rangulicon,项目名称:mkvmanager,代码行数:11,代码来源:autoload.php

示例4: handleDsn

 protected function handleDsn($value)
 {
     try {
         $ts = ezcTestSettings::getInstance();
         $settings = ezcDbFactory::parseDSN($value);
         $ts->db->value = $value;
         try {
             $ts->setDatabaseSettings($settings);
             $db = ezcDbFactory::create($settings);
             ezcDbInstance::set($db);
         } catch (ezcDbException $e) {
             die($e->getMessage());
         }
     } catch (Exception $e) {
         die("Database initialization error: {$e->getMessage()}\n");
     }
 }
开发者ID:naderman,项目名称:pflow,代码行数:17,代码来源:runner.php

示例5: __construct

 /**
  * Db constructor
  * @param array|string $dsn Connection DSN string or array of parameters
  * @return void
  */
 public function __construct($dsn = '')
 {
     $db = \ezcDbFactory::create($dsn);
     \ezcDbInstance::set($db);
 }
开发者ID:heshuxian,项目名称:mofang,代码行数:10,代码来源:Db.php

示例6: PDO

<?php

require_once __DIR__ . '/tutorial_example_01.php';
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
// $db = new ezcDbHandlerMysql($pdo);
$db = ezcDbFactory::wrapper($pdo);
ezcDbInstance::set($db, 'wrapper');
ezcDbInstance::chooseDefault('wrapper');
$db = ezcDbInstance::get();
$res = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
print_r($db);
print_r($res);
echo "\n----\n";
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
// $db = new ezcDbHandlerMysql($pdo);
$db = ezcDbFactory::create($pdo);
ezcDbInstance::set($db, 'wrapper-1');
ezcDbInstance::chooseDefault('wrapper-1');
$db = ezcDbInstance::get();
$res = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
print_r($db);
print_r($res);
开发者ID:fobiaweb,项目名称:ezc-database,代码行数:22,代码来源:tutorial_example_01b.php

示例7: ini_set

<?php

//ini_set( 'include_path', ini_get( 'include_path' ) . ':/htdocs/ezc_trunk/:.' );
ini_set('session.gc_maxlifetime', 864000);
require 'Base/src/ezc_bootstrap.php';
// ezcDbInstance::set( ezcDbFactory::create( 'sqlite://'. dirname( __FILE__ ) . '/share.sqlite' ) );
ezcDbInstance::set(ezcDbFactory::create('mysql://root:cawerks@127.0.0.1/UnTrucBien'));
$options = new ezcBaseAutoloadOptions(array('debug' => true));
ezcBase::setOptions($options);
ezcBase::addClassRepository(dirname(__FILE__) . '/lib/share', null, 'share');
ezcBase::addClassRepository(dirname(__FILE__) . '/lib/debug', null, 'debug');
$log = ezcLog::getInstance();
$mapper = $log->getMapper();
$writer = new ezcLogUnixFileWriter("/tmp", "thewire-web.log");
$filter = new ezcLogFilter();
$rule = new ezcLogFilterRule($filter, $writer, true);
$mapper->appendRule($rule);
$reader = new ezcConfigurationIniReader();
$reader->init(dirname(__FILE__), 'settings');
$ini = $reader->load();
if ($ini->getBoolSetting('DevelopmentSettings', 'Debug')) {
    ezcBase::setRunMode(ezcBase::MODE_DEVELOPMENT);
    $debugHandler = ezcDebug::getInstance();
    $debugHandler->setOutputFormatter(new debugHtmlFormatter());
    debugLogger::setHandler($debugHandler);
}
$tc = ezcTemplateConfiguration::getInstance();
$tc->templatePath = dirname(__FILE__) . '/templates';
$tc->compilePath = dirname(__FILE__) . '/cache';
$tc->addExtension("shareTemplateFunctions");
开发者ID:jeanvoye,项目名称:utb,代码行数:30,代码来源:config.php

示例8: __construct

 /**
  * @internal
  */
 public function __construct($userSettings = null)
 {
     $configDir = '.';
     // Пользовательские настройки
     // --------------------------
     if (!is_array($userSettings)) {
         $userSettings = array('file' => $userSettings);
     }
     if ($file = @$userSettings['file']) {
         unset($userSettings['file']);
         if (file_exists($file)) {
             $configDir = dirname($file);
             $settings = Utils::loadConfig($file);
             Log::debug("Configuration load: " . realpath($file));
             unset($file);
             $userSettings = array_merge($userSettings, $settings);
         }
     }
     $userSettings = array_merge($this->defaultsSettings, $userSettings);
     if ($p = $userSettings['templates.path']) {
         if (substr($p, 0, 1) !== '/') {
             $userSettings['templates.path'] = SYSPATH . '/' . $p;
         }
     }
     // if (is_array($userSettings['import'])) {
     //     $import = $userSettings['import'];
     //     foreach ($import as $file) {
     //         $file     = $configDir . '/' . $file;
     //         $settings = Utils::loadConfig($file);
     //         if ($settings) {
     //             $defaultSettings = array_merge($defaultSettings, $settings);
     //             Log::debug("Configuration import",
     //                               array(realpath($file)));
     //         }
     //     }
     // }
     parent::__construct((array) $userSettings);
     $app =& $this;
     // Если Internet Explorer, то шлем на хуй
     /*
      if (preg_match('/(rv:11.0|MSIE)/i', $_SERVER['HTTP_USER_AGENT'])) {
      $app->log->warning('Bad Browser ', array('HTTP_USER_AGENT'=>$_SERVER['HTTP_USER_AGENT']));
      $app->redirect( "http://fobia.github.io/docs/badbrowser.html" );
      exit();
      }
     */
     // // Автоматическая загрузка секций конфигурации
     // ----------------------------------------------
     $autoload = $this['settings']['app.autoload'];
     if ($autoload) {
         $this['settings']['app'] = new \Pimple();
         $this['settings']['app']['autoload'] = $autoload;
         if (is_array($autoload)) {
             foreach (@$autoload as $cfg => $file) {
                 $this['settings']['app'][$cfg] = function ($c) use($cfg, $file, $configDir) {
                     Log::debug(">> autoload config", array($cfg, $file));
                     if (!file_exists($configDir . "/{$file}")) {
                         trigger_error("Нет автозагрузочной секции конфигурации '{$cfg}'" . "/{$file}", E_USER_ERROR);
                         return;
                     }
                     return Utils::loadConfig($file);
                 };
             }
         }
     }
     unset($autoload, $cfg, $file);
     // Session
     //  session.gc_maxlifetime = 1440
     //  ;setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
     // ------------------
     $this['session'] = function ($c) {
         $sid = null;
         if ($c['settings']['session.cookie'] && @$_COOKIE['SID']) {
             $sid = $_COOKIE['SID'];
             session_id($sid);
         }
         $session = new \Slim\Session($c['settings']['session.handler']);
         @$session->start();
         if ($c['settings']['session.encrypt'] === true) {
             $session->decrypt($c['crypt']);
         }
         if ($sid === null) {
             $sid = session_id();
             if ($c['settings']['session.cookie']) {
                 @$c->setCookie('SID', $sid, time() + 1440);
                 Log::debug('Session save cookie');
             }
         }
         Log::debug('Session start', array($sid));
         return $session;
     };
     // View
     // ------------------
     $this['view'] = function ($c) {
         $view = $c['settings']['view'];
         if ($view instanceof \Slim\Interfaces\ViewInterface !== false) {
             return $view;
//.........这里部分代码省略.........
开发者ID:fobiaweb,项目名称:base,代码行数:101,代码来源:Application.php

示例9:

<?php

require 'ezc-setup.php';
$db1 = ezcDbFactory::create('mysql://root@localhost/ezc');
ezcDbInstance::set($db1, 'ezc');
$trunk = ezcDbFactory::create('mysql://root@localhost/trip');
ezcDbInstance::set($trunk, 'ezt');
$db = ezcDbInstance::get('ezt');
echo $db->getName();
开发者ID:SandyS1,项目名称:presentations,代码行数:9,代码来源:database.php

示例10: __construct

 public function __construct()
 {
     $db = ezcDbFactory::create('mysql://user:password@127.0.0.1/stats');
     ezcDbInstance::set($db);
 }
开发者ID:naderman,项目名称:stats-o-matic,代码行数:5,代码来源:DatabaseAccess.php


注:本文中的ezcDbInstance::set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。