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


PHP MDB2::setOptions方法代码示例

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


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

示例1: singleton

 /**
  * Returns a MDB2 connection with the requested DSN.
  * A new MDB2 connection object is only created if no object with the
  * requested DSN exists yet.
  *
  * @param   mixed   'data source name', see the MDB2::parseDSN
  *                            method for a description of the dsn format.
  *                            Can also be specified as an array of the
  *                            format returned by MDB2::parseDSN.
  * @param   array   An associative array of option names and
  *                            their values.
  *
  * @return  mixed   a newly created MDB2 connection object, or a MDB2
  *                  error object on error
  *
  * @access  public
  * @see     MDB2::parseDSN
  */
 static function singleton($dsn = null, $options = false)
 {
     if ($dsn) {
         $dsninfo = MDB2::parseDSN($dsn);
         $dsninfo = array_merge($GLOBALS['_MDB2_dsninfo_default'], $dsninfo);
         $keys = array_keys($GLOBALS['_MDB2_databases']);
         for ($i = 0, $j = count($keys); $i < $j; ++$i) {
             if (isset($GLOBALS['_MDB2_databases'][$keys[$i]])) {
                 $tmp_dsn = $GLOBALS['_MDB2_databases'][$keys[$i]]->getDSN('array');
                 if (count(array_diff_assoc($tmp_dsn, $dsninfo)) == 0) {
                     MDB2::setOptions($GLOBALS['_MDB2_databases'][$keys[$i]], $options);
                     return $GLOBALS['_MDB2_databases'][$keys[$i]];
                 }
             }
         }
     } elseif (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) {
         return $GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])];
     }
     $db = MDB2::factory($dsn, $options);
     return $db;
 }
开发者ID:Alphenus,项目名称:ilmomasiina-php,代码行数:39,代码来源:MDB2.php

示例2: array

 /**
  * Returns a MDB2 connection with the requested DSN.
  * A newnew MDB2 connection object is only created if no object with the
  * reuested DSN exists yet.
  *
  * IMPORTANT: In order for MDB2 to work properly it is necessary that
  * you make sure that you work with a reference of the original
  * object instead of a copy (this is a PHP4 quirk).
  *
  * For example:
  *     $mdb =& MDB2::singleton($dsn);
  *          ^^
  * And not:
  *     $mdb = MDB2::singleton($dsn);
  *          ^^
  *
  * @param   mixed   $dsn      'data source name', see the MDB2::parseDSN
  *                            method for a description of the dsn format.
  *                            Can also be specified as an array of the
  *                            format returned by MDB2::parseDSN.
  * @param   array   $options  An associative array of option names and
  *                            their values.
  * @return  mixed   a newly created MDB2 connection object, or a MDB2
  *                  error object on error
  * @access  public
  * @see     MDB2::parseDSN
  */
 function &singleton($dsn = null, $options = false)
 {
     if ($dsn) {
         $dsninfo = MDB2::parseDSN($dsn);
         $dsninfo_default = array('phptype' => false, 'dbsyntax' => false, 'username' => false, 'password' => false, 'protocol' => false, 'hostspec' => false, 'port' => false, 'socket' => false, 'database' => false, 'mode' => false);
         $dsninfo = array_merge($dsninfo_default, $dsninfo);
         $keys = array_keys($GLOBALS['_MDB2_databases']);
         for ($i = 0, $j = count($keys); $i < $j; ++$i) {
             $tmp_dsn = $GLOBALS['_MDB2_databases'][$keys[$i]]->getDSN('array');
             if (count(array_diff($tmp_dsn, $dsninfo)) == 0) {
                 MDB2::setOptions($GLOBALS['_MDB2_databases'][$keys[$i]], $options);
                 return $GLOBALS['_MDB2_databases'][$keys[$i]];
             }
         }
     } else {
         if (is_array($GLOBALS['_MDB2_databases']) && reset($GLOBALS['_MDB2_databases'])) {
             $db =& $GLOBALS['_MDB2_databases'][key($GLOBALS['_MDB2_databases'])];
             return $db;
         }
     }
     $db =& MDB2::connect($dsn, $options);
     return $db;
 }
开发者ID:BackupTheBerlios,项目名称:smart-svn,代码行数:50,代码来源:MDB2.php

示例3: OX_increaseMemoryLimit

@set_time_limit(600);
OX_increaseMemoryLimit(OX_getMinimumRequiredMemory('cache'));
error_reporting(E_ALL & ~(E_NOTICE | E_WARNING | E_DEPRECATED | E_STRICT));
if (!is_writable(RV_PATH . '/etc/xmlcache')) {
    die("=> The directory " . RV_PATH . '/etc/xmlcache' . " is not writable\n");
}
require RV_PATH . '/lib/OA/DB/Table.php';
// Create a database mock so we will not have to connect to database itself
require_once RV_PATH . '/lib/simpletest/mock_objects.php';
require_once 'MDB2/Driver/mysql.php';
Mock::generatePartial('MDB2_Driver_mysql', 'MDB2_Mock', array());
$oDbh = new MDB2_Mock();
$oDbh->__construct();
// add datatype mapping
$aDatatypeOptions = OA_DB::getDatatypeMapOptions();
MDB2::setOptions($oDbh, $aDatatypeOptions);
$oCache = new OA_DB_XmlCache();
$aOptions = array('force_defaults' => false);
$aSkipFiles = array();
clean_up();
// Generate XML caches
generateXmlCache(glob(RV_PATH . '/etc/tables_*.xml'));
generateXmlCache(glob(RV_PATH . '/etc/changes/schema_tables_*.xml'));
generateXmlCache(glob(RV_PATH . '/etc/changes/changes_tables_*.xml'), 'parseChangesetDefinitionFile');
echo "=> FINISHED REFRESHING THE MDB2 SCHEMA XML FILE CACHE\n\n";
function generateXmlCache($xmlFiles, $callback = 'parseDatabaseDefinitionFile')
{
    global $aSkipFiles, $aOptions, $oDbh, $oCache;
    foreach ($xmlFiles as $fileName) {
        if (!in_array(baseName($fileName), $aSkipFiles)) {
            echo "  => " . basename($fileName) . ": ";
开发者ID:akirsch,项目名称:revive-adserver,代码行数:31,代码来源:buildXmlCache.php


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