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


PHP DB_DataObject::getDatabaseConnection方法代码示例

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


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

示例1: __construct

 public function __construct(DB_DataObject $do, $values)
 {
     $this->do = $do;
     if (!is_array($values)) {
         throw new Exception('Values must be an array !');
     }
     $this->values = $values;
     $this->db = $do->getDatabaseConnection();
 }
开发者ID:demental,项目名称:m,代码行数:9,代码来源:Search.php

示例2: connectToDatabase

 /**
  * Connect to the database.
  *
  * @return void
  * @access public
  */
 public static function connectToDatabase()
 {
     global $configArray;
     if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
         define('DB_DATAOBJECT_NO_OVERLOAD', 0);
     }
     $options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options');
     // If we're using PostgreSQL, we need to set up some extra configuration
     // settings so that unique ID sequences are properly registered:
     if (substr($configArray['Database']['database'], 0, 5) == 'pgsql') {
         $tables = array('comments', 'oai_resumption', 'resource', 'resource_tags', 'search', 'session', 'tags', 'user', 'user_list', 'user_resource');
         foreach ($tables as $table) {
             $configArray['Database']['sequence_' . $table] = $table . '_id_seq';
         }
     }
     $options = $configArray['Database'];
     if (substr($configArray['Database']['database'], 0, 5) == 'mysql') {
         // If we're using MySQL, we need to make certain adjustments (ANSI
         // quotes, pipes as concatenation operator) for proper compatibility
         // with code built for other database systems like PostgreSQL or Oracle.
         $obj = new DB_DataObject();
         $conn = $obj->getDatabaseConnection();
         $conn->query("SET @@SESSION.sql_mode='ANSI_QUOTES,PIPES_AS_CONCAT'");
     } else {
         if (substr($configArray['Database']['database'], 0, 4) == 'oci8') {
             // If we are using Oracle, set some portability values:
             $temp_db = new DB_DataObject();
             $db =& $temp_db->getDatabaseConnection();
             $db->setOption('portability', DB_PORTABILITY_NUMROWS | DB_PORTABILITY_NULL_TO_EMPTY);
             // Update the date format to fix issues with Oracle being evil
             $db->query("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
         }
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:40,代码来源:ConnectionManager.php

示例3: getTagsArray

 /**
  * @param DB_DataObject $obj the recordset on which the select query will be executed
  */
 public function getTagsArray($obj)
 {
     if (is_array($obj->_tagplugin_cache)) {
         return $obj->_tagplugin_cache;
     }
     if (empty($obj->tagplugin_cache)) {
         $tag = DB_DataObject::factory('tag');
         $dbo = DB_DataObject::factory('tag_record');
         $dbo->tagged_table = $obj->tableName();
         $dbo->record_id = $obj->pk();
         $tag->selectAdd();
         $tag->selectAdd('tag.id,tag.strip');
         $tag->joinAdd($dbo);
         $tag->selectAs($dbo, 'link_%s');
         $tag->find();
         $obj->tagplugin_cache = '|';
         while ($tag->fetch()) {
             if (empty($tag->strip)) {
                 continue;
             }
             $obj->tagplugin_cache .= $tag->strip . '|';
             $obj->_tagplugin_cache[] = $tag->strip;
         }
         $db = $obj->getDatabaseConnection();
         $query = sprintf('UPDATE %s SET tagplugin_cache=:cacheval where %s = :pkval', $db->quoteIdentifier($obj->tableName()), $db->quoteIdentifier($obj->pkName()));
         $sth = $db->prepare($query, array('text', 'text'));
         if (PEAR::isError($sth)) {
             throw new Exception($sth->getMessage() . ' HINT: check if your table has a tagplugin_cache field');
         }
         $sth->execute(array('cacheval' => $obj->tagplugin_cache, 'pkval' => $obj->pk()));
     }
     $obj->_tagplugin_cache = explode('|', $obj->tagplugin_cache);
     return $obj->_tagplugin_cache;
 }
开发者ID:demental,项目名称:m,代码行数:37,代码来源:db.php


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