|
From: <rgr...@us...> - 2013-08-20 17:12:19
|
Revision: 11954
http://sourceforge.net/p/xoops/svn/11954
Author: rgriffith
Date: 2013-08-20 17:12:12 +0000 (Tue, 20 Aug 2013)
Log Message:
-----------
First pass from redheadedrod
All core database calls are directed explicitly to legacy support. A basic Doctrine connection is available, so new code can be built to that API and core conversion can begin.
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/functions.ini.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/object.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/databasefactory.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/manager.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabase.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xml/rpc/xoopsapi.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopslists.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopsload.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/include/common.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/block.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/blockmodulelink.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/cachemodel.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configcategory.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configitem.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configoption.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/group.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/groupperm.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/member.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/membership.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/module.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/object.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/online.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/privmessage.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/ranks.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/session.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/tplfile.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/tplset.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/user.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/lostpass.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/avatars/admin/avatar_custom.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/avatars/admin/avatar_system.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/avatars/class/avatar.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/avatars/class/userlink.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/avatars/editavatar.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/avatars/include/install.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/banners/class/banner.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/banners/class/bannerclient.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/banners/class/bannerrender.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/banners/include/install.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/comments/class/comment.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/comments/include/install.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/images/class/category.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/images/class/image.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/images/class/imagebody.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/logger/plugins/firephp/logger.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/logger/plugins/legacy/render.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/logger/plugins/pqp/logger.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/logger/preloads/core.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/maintenance/admin/center.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/maintenance/admin/dump.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/maintenance/class/maintenance.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/menus/class/menu.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/menus/class/menus.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/notifications/class/notification.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/notifications/include/install.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/page/class/page_content.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/page/class/page_rating.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/page/class/page_related.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/page/class/page_related_link.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/page/class/plugin/notifications.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/page/class/plugin/search.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/pm/class/message.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/pm/include/install.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/pm/include/update.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/class/category.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/class/field.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/class/profile.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/class/regstep.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/class/visibility.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/include/install.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/include/update.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/lostpass.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/profile/search.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/admin/advisory.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/admin/center.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/admin/index.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/admin/prefix_manager.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/class/form/center.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/class/protector.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/include/postcheck.inc.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/protector/include/postcheck_functions.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/admin/permissions.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/archive.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/category.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/file.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/item.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/mimetype.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/permission.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/plugin/notifications.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/class/rating.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/publisher/search.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/smilies/class/smiley.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/system/admin/users/jquery.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/system/admin/users/users.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/system/blocks/info.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/system/class/module.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/system/include/update.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/userconfigs/class/item.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/modules/userconfigs/class/option.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/pda.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Auth/Ads.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Auth/Factory.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Auth/Ldap.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Auth/Xoops.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Auth.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Object/Dtype/Abstract.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops.php
Added Paths:
-----------
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/xoopsdatabase.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/composer.json
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/vendor/
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/functions.ini.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/functions.ini.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/functions.ini.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -152,7 +152,7 @@
if ($isRel) {
return $relative_name;
}
- return $xoops->db()->prefix($relative_name);
+ return $xoopsDB->prefix($relative_name);
}
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/object.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/object.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/Frameworks/art/object.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -62,7 +62,7 @@
/**
* Constructor
*
- * @param object $db reference to the {@link XoopsDatabase} object
+ * @param object $db reference to the {@link XoopsConnection} object
**/
function __construct($db, $table, $className, $keyName, $identifierName)
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/databasefactory.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/databasefactory.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/databasefactory.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -36,17 +36,52 @@
*/
static function getDatabaseConnection()
{
+ global $xoopsDB;
static $instance;
if (!isset($instance)) {
- if (XoopsLoad::fileExists($file = XOOPS_ROOT_PATH . '/class/database/' . XOOPS_DB_TYPE . 'database.php')) {
- require_once $file;
-
+ //New database connector
+ require_once XOOPS_ROOT_PATH . '/class/database/xoopsdatabase.php';
+ $config = new \Doctrine\DBAL\Configuration();
+ $connectionParams = array(
+ 'dbname' => XOOPS_DB_NAME,
+ 'user' => XOOPS_DB_USER,
+ 'password' => XOOPS_DB_PASS,
+ 'host' => XOOPS_DB_HOST,
+// 'port' => ?,
+// 'unix_socket' => ?,
+ 'charset' => XOOPS_DB_CHARSET,
+ 'driver' => 'pdo_mysql',
+ 'wrapperClass' => 'XoopsConnection'
+ );
+ $instance = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
+ // Legacy support
+ if (isset($instance)) {
+ require_once XOOPS_ROOT_PATH . '/class/database/mysqldatabase.php';
if (!defined('XOOPS_DB_PROXY')) {
$class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseSafe';
} else {
$class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseProxy';
}
+ $xoopsPreload = XoopsPreload::getInstance();
+ $xoopsPreload->triggerEvent('core.class.database.databasefactory.connection', array(&$class));
+ $xoopsDB = new $class();
+ $xoopsDB->setPrefix(XOOPS_DB_PREFIX);
+ $xoopsDB->conn = $instance;
+ } else {
+ $xoopsDB = null;
+ $xoopsPreload = XoopsPreload::getInstance();
+ trigger_error('notrace:Unable to connect to database', E_USER_ERROR);
+ }
+ }
+ //echo '<pre>'.print_r($xoopsDB, true).print_r($instance, true) . '</pre>'. 'done... <br />';
+ return $instance;
+ }
+ static function getNewDatabaseConnection()
+ {
+ static $instance;
+ if (!isset($instance)) {
+ require_once 'xoopsdatabase.php';
$xoopsPreload = XoopsPreload::getInstance();
$xoopsPreload->triggerEvent('core.class.database.databasefactory.connection', array(&$class));
/* @var $instance XoopsDatabase */
@@ -55,9 +90,6 @@
if (!$instance->connect()) {
trigger_error('notrace:Unable to connect to database', E_USER_ERROR);
}
- } else {
- trigger_error('notrace:Failed to load database of type: ' . XOOPS_DB_TYPE . ' in file: ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING);
- }
}
return $instance;
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/manager.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/manager.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/manager.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -1,340 +1,342 @@
-<?php
-/*
- You may not change or alter any portion of this comment or credits
- of supporting developers from this source code or any supporting source code
- which is considered copyrighted (c) material of the original comment or credit authors.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-*/
-
-/**
- * Database manager for XOOPS
- *
- * @copyright The XOOPS project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package class
- * @subpackage database
- * @since 2.6.0
- * @author Haruki Setoyama <ha...@pl...>
- * @version $Id$
- */
-
-class XoopsDatabaseManager
-{
- /**
- * @var array
- */
- private $s_tables = array();
-
- /**
- * @var array
- */
- private $f_tables = array();
-
- /**
- * @var XoopsDatabase
- */
- public $db;
-
- /**
- * @var array
- */
- public $successStrings = array();
-
- /**
- * @var array
- */
- public $failureStrings = array();
-
- /**
- *
- */
- public function __construct()
- {
- $xoops = Xoops::getInstance();
- $this->db = $xoops->db();
- $this->db->setPrefix(XOOPS_DB_PREFIX);
- $this->successStrings = array(
- 'create' => XoopsLocale::SF_TABLE_CREATED,
- 'insert' => XoopsLocale::SF_ENTRIES_INSERTED_TO_TABLE,
- 'alter' => XoopsLocale::SF_TABLE_UPDATED,
- 'drop' => XoopsLocale::SF_TABLE_DROPPED,
- );
- $this->failureStrings = array(
- 'create' => XoopsLocale::EF_TABLE_NOT_CREATED,
- 'insert' => XoopsLocale::EF_ENTRIES_NOT_INSERTED_TO_TABLE,
- 'alter' => XoopsLocale::EF_TABLE_NOT_UPDATED,
- 'drop' => XoopsLocale::EF_TABLE_NOT_DROPPED,
- );
- }
-
- /**
- * @return bool
- */
- public function isConnectable()
- {
- return ($this->db->connect(false) != false) ? true : false;
- }
-
- /**
- * @return bool
- */
- public function dbExists()
- {
- return ($this->db->connect() != false) ? true : false;
- }
-
- /**
- * @return bool
- */
- public function createDB()
- {
- $this->db->connect(false);
-
- $result = $this->db->query("CREATE DATABASE " . XOOPS_DB_NAME);
-
- return ($result != false) ? true : false;
- }
-
- /**
- * @param string $sql_file_path
- * @param bool $force
- *
- * @return bool
- */
- public function queryFromFile($sql_file_path, $force = false)
- {
- if (!XoopsLoad::fileExists($sql_file_path)) {
- return false;
- }
- $queryFunc = (bool)$force ? "queryF" : "query";
- $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
- SqlUtility::splitMySqlFile($pieces, $sql_query);
- $this->db->connect();
- foreach ($pieces as $piece) {
- $piece = trim($piece);
- // [0] contains the prefixed query
- // [4] contains unprefixed table name
- $prefixed_query = SqlUtility::prefixQuery($piece, $this->db->prefix());
- if ($prefixed_query != false) {
- $table = $this->db->prefix($prefixed_query[4]);
- if ($prefixed_query[1] == 'CREATE TABLE') {
- if ($this->db->$queryFunc($prefixed_query[0]) != false) {
- if (!isset($this->s_tables['create'][$table])) {
- $this->s_tables['create'][$table] = 1;
- }
- } else {
- if (!isset($this->f_tables['create'][$table])) {
- $this->f_tables['create'][$table] = 1;
- }
- }
- } else {
- if ($prefixed_query[1] == 'INSERT INTO') {
- if ($this->db->$queryFunc($prefixed_query[0]) != false) {
- if (!isset($this->s_tables['insert'][$table])) {
- $this->s_tables['insert'][$table] = 1;
- } else {
- $this->s_tables['insert'][$table]++;
- }
- } else {
- if (!isset($this->f_tables['insert'][$table])) {
- $this->f_tables['insert'][$table] = 1;
- } else {
- $this->f_tables['insert'][$table]++;
- }
- }
- } else {
- if ($prefixed_query[1] == 'ALTER TABLE') {
- if ($this->db->$queryFunc($prefixed_query[0]) != false) {
- if (!isset($this->s_tables['alter'][$table])) {
- $this->s_tables['alter'][$table] = 1;
- }
- } else {
- if (!isset($this->s_tables['alter'][$table])) {
- $this->f_tables['alter'][$table] = 1;
- }
- }
- } else {
- if ($prefixed_query[1] == 'DROP TABLE') {
- if ($this->db->$queryFunc('DROP TABLE ' . $table) != false) {
- if (!isset($this->s_tables['drop'][$table])) {
- $this->s_tables['drop'][$table] = 1;
- }
- } else {
- if (!isset($this->s_tables['drop'][$table])) {
- $this->f_tables['drop'][$table] = 1;
- }
- }
- }
- }
- }
- }
- }
- }
- return true;
- }
-
- /**
- * @return string
- */
- public function report()
- {
- $commands = array('create', 'insert', 'alter', 'drop');
- $content = '<ul class="log">';
- foreach ($commands as $cmd) {
- if (!@empty($this->s_tables[$cmd])) {
- foreach ($this->s_tables[$cmd] as $key => $val) {
- $content .= '<li class="success">';
- $content .= ($cmd != 'insert') ? sprintf($this->successStrings[$cmd], $key) : sprintf($this->successStrings[$cmd], $val, $key);
- $content .= "</li>\n";
- }
- }
- }
- foreach ($commands as $cmd) {
- if (!@empty($this->f_tables[$cmd])) {
- foreach ($this->f_tables[$cmd] as $key => $val) {
- $content .= '<li class="failure">';
- $content .= ($cmd != 'insert') ? sprintf($this->failureStrings[$cmd], $key) : sprintf($this->failureStrings[$cmd], $val, $key);
- $content .= "</li>\n";
- }
- }
- }
- $content .= '</ul>';
- return $content;
- }
-
- /**
- * @param string $sql
- *
- * @return mixed
- */
- public function query($sql)
- {
- $this->db->connect();
- return $this->db->query($sql);
- }
-
- /**
- * @param $table
- *
- * @return string
- */
- public function prefix($table)
- {
- $this->db->connect();
- return $this->db->prefix($table);
- }
-
- /**
- * @param $ret
- *
- * @return array
- */
- public function fetchArray($ret)
- {
- $this->db->connect();
- return $this->db->fetchArray($ret);
- }
-
- /**
- * @param $table
- * @param $query
- *
- * @return bool|void
- */
- public function insert($table, $query)
- {
- $this->db->connect();
- $table = $this->db->prefix($table);
- $query = 'INSERT INTO ' . $table . ' ' . $query;
- if (!$this->db->queryF($query)) {
- if (!isset($this->f_tables['insert'][$table])) {
- $this->f_tables['insert'][$table] = 1;
- } else {
- $this->f_tables['insert'][$table]++;
- }
- return false;
- } else {
- if (!isset($this->s_tables['insert'][$table])) {
- $this->s_tables['insert'][$table] = 1;
- } else {
- $this->s_tables['insert'][$table]++;
- }
- return $this->db->getInsertId();
- }
- }
-
- /**
- * @return bool
- */
- public function isError()
- {
- return (isset($this->f_tables)) ? true : false;
- }
-
- /**
- * @param $tables
- *
- * @return array
- */
- public function deleteTables($tables)
- {
- $deleted = array();
- $this->db->connect();
- foreach ($tables as $key => $val) {
- if (!$this->db->query("DROP TABLE " . $this->db->prefix($key))) {
- $deleted[] = $val;
- }
- }
- return $deleted;
- }
-
- /**
- * @param $table
- *
- * @return bool
- */
- public function tableExists($table)
- {
- $table = trim($table);
- $ret = false;
- if ($table != '') {
- $this->db->connect();
- $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix($table);
- $ret = (false != $this->db->query($sql)) ? true : false;
- }
- return $ret;
- }
-
- /**
- * This method allows to copy fields from one table to another
- *
- * @param array $fieldsMap Map of the fields
- * ex: array('oldfieldname' => 'newfieldname');
- * @param string $oTableName Old Table
- * @param string $nTableName New Table
- * @param bool $dropTable Drop old Table
- */
- public function copyFields($fieldsMap, $oTableName, $nTableName, $dropTable = false)
- {
- $sql = "SHOW COLUMNS FROM " . $this->db->prefix($oTableName);
- $result = $this->db->queryF($sql);
- if (($rows = $this->db->getRowsNum($result)) == count($fieldsMap)) {
- $sql = "SELECT * FROM " . $this->db->prefix($oTableName);
- $result = $this->db->queryF($sql);
- while ($myrow = $this->db->fetchArray($result)) {
- ksort($fieldsMap);
- ksort($myrow);
- $sql = "INSERT INTO `" . $this->db->prefix($nTableName) . "` " . "(`" . implode("`,`", $fieldsMap) . "`)" . " VALUES ('" . implode("','", $myrow) . "')";
-
- $this->db->queryF($sql);
- }
- if ($dropTable) {
- $sql = "DROP TABLE " . $this->db->prefix($oTableName);
- $this->db->queryF($sql);
- }
- }
- }
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+/**
+ * Database manager for XOOPS
+ *
+ * @copyright The XOOPS project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package class
+ * @subpackage database
+ * @since 2.6.0
+ * @author Haruki Setoyama <ha...@pl...>
+ * @version $Id$
+ */
+
+class XoopsDatabaseManager
+{
+ /**
+ * @var array
+ */
+ private $s_tables = array();
+
+ /**
+ * @var array
+ */
+ private $f_tables = array();
+
+ /**
+ * @var XoopsDatabase
+ */
+ public $db;
+
+ /**
+ * @var array
+ */
+ public $successStrings = array();
+
+ /**
+ * @var array
+ */
+ public $failureStrings = array();
+
+ /**
+ *
+ */
+ public function __construct()
+ {
+ $xoops = Xoops::getInstance();
+ $xoops->db();
+ global $xoopsDB;
+ $this->db = $xoopsDB;
+ $this->db->setPrefix(XOOPS_DB_PREFIX);
+ $this->successStrings = array(
+ 'create' => XoopsLocale::SF_TABLE_CREATED,
+ 'insert' => XoopsLocale::SF_ENTRIES_INSERTED_TO_TABLE,
+ 'alter' => XoopsLocale::SF_TABLE_UPDATED,
+ 'drop' => XoopsLocale::SF_TABLE_DROPPED,
+ );
+ $this->failureStrings = array(
+ 'create' => XoopsLocale::EF_TABLE_NOT_CREATED,
+ 'insert' => XoopsLocale::EF_ENTRIES_NOT_INSERTED_TO_TABLE,
+ 'alter' => XoopsLocale::EF_TABLE_NOT_UPDATED,
+ 'drop' => XoopsLocale::EF_TABLE_NOT_DROPPED,
+ );
+ }
+
+ /**
+ * @return bool
+ */
+ public function isConnectable()
+ {
+ return ($this->db->connect(false) != false) ? true : false;
+ }
+
+ /**
+ * @return bool
+ */
+ public function dbExists()
+ {
+ return ($this->db->connect() != false) ? true : false;
+ }
+
+ /**
+ * @return bool
+ */
+ public function createDB()
+ {
+ $this->db->connect(false);
+
+ $result = $this->db->query("CREATE DATABASE " . XOOPS_DB_NAME);
+
+ return ($result != false) ? true : false;
+ }
+
+ /**
+ * @param string $sql_file_path
+ * @param bool $force
+ *
+ * @return bool
+ */
+ public function queryFromFile($sql_file_path, $force = false)
+ {
+ if (!XoopsLoad::fileExists($sql_file_path)) {
+ return false;
+ }
+ $queryFunc = (bool)$force ? "queryF" : "query";
+ $sql_query = trim(fread(fopen($sql_file_path, 'r'), filesize($sql_file_path)));
+ SqlUtility::splitMySqlFile($pieces, $sql_query);
+ $this->db->connect();
+ foreach ($pieces as $piece) {
+ $piece = trim($piece);
+ // [0] contains the prefixed query
+ // [4] contains unprefixed table name
+ $prefixed_query = SqlUtility::prefixQuery($piece, $this->db->prefix());
+ if ($prefixed_query != false) {
+ $table = $this->db->prefix($prefixed_query[4]);
+ if ($prefixed_query[1] == 'CREATE TABLE') {
+ if ($this->db->$queryFunc($prefixed_query[0]) != false) {
+ if (!isset($this->s_tables['create'][$table])) {
+ $this->s_tables['create'][$table] = 1;
+ }
+ } else {
+ if (!isset($this->f_tables['create'][$table])) {
+ $this->f_tables['create'][$table] = 1;
+ }
+ }
+ } else {
+ if ($prefixed_query[1] == 'INSERT INTO') {
+ if ($this->db->$queryFunc($prefixed_query[0]) != false) {
+ if (!isset($this->s_tables['insert'][$table])) {
+ $this->s_tables['insert'][$table] = 1;
+ } else {
+ $this->s_tables['insert'][$table]++;
+ }
+ } else {
+ if (!isset($this->f_tables['insert'][$table])) {
+ $this->f_tables['insert'][$table] = 1;
+ } else {
+ $this->f_tables['insert'][$table]++;
+ }
+ }
+ } else {
+ if ($prefixed_query[1] == 'ALTER TABLE') {
+ if ($this->db->$queryFunc($prefixed_query[0]) != false) {
+ if (!isset($this->s_tables['alter'][$table])) {
+ $this->s_tables['alter'][$table] = 1;
+ }
+ } else {
+ if (!isset($this->s_tables['alter'][$table])) {
+ $this->f_tables['alter'][$table] = 1;
+ }
+ }
+ } else {
+ if ($prefixed_query[1] == 'DROP TABLE') {
+ if ($this->db->$queryFunc('DROP TABLE ' . $table) != false) {
+ if (!isset($this->s_tables['drop'][$table])) {
+ $this->s_tables['drop'][$table] = 1;
+ }
+ } else {
+ if (!isset($this->s_tables['drop'][$table])) {
+ $this->f_tables['drop'][$table] = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @return string
+ */
+ public function report()
+ {
+ $commands = array('create', 'insert', 'alter', 'drop');
+ $content = '<ul class="log">';
+ foreach ($commands as $cmd) {
+ if (!@empty($this->s_tables[$cmd])) {
+ foreach ($this->s_tables[$cmd] as $key => $val) {
+ $content .= '<li class="success">';
+ $content .= ($cmd != 'insert') ? sprintf($this->successStrings[$cmd], $key) : sprintf($this->successStrings[$cmd], $val, $key);
+ $content .= "</li>\n";
+ }
+ }
+ }
+ foreach ($commands as $cmd) {
+ if (!@empty($this->f_tables[$cmd])) {
+ foreach ($this->f_tables[$cmd] as $key => $val) {
+ $content .= '<li class="failure">';
+ $content .= ($cmd != 'insert') ? sprintf($this->failureStrings[$cmd], $key) : sprintf($this->failureStrings[$cmd], $val, $key);
+ $content .= "</li>\n";
+ }
+ }
+ }
+ $content .= '</ul>';
+ return $content;
+ }
+
+ /**
+ * @param string $sql
+ *
+ * @return mixed
+ */
+ public function query($sql)
+ {
+ $this->db->connect();
+ return $this->db->query($sql);
+ }
+
+ /**
+ * @param $table
+ *
+ * @return string
+ */
+ public function prefix($table)
+ {
+ $this->db->connect();
+ return $this->db->prefix($table);
+ }
+
+ /**
+ * @param $ret
+ *
+ * @return array
+ */
+ public function fetchArray($ret)
+ {
+ $this->db->connect();
+ return $this->db->fetchArray($ret);
+ }
+
+ /**
+ * @param $table
+ * @param $query
+ *
+ * @return bool|void
+ */
+ public function insert($table, $query)
+ {
+ $this->db->connect();
+ $table = $this->db->prefix($table);
+ $query = 'INSERT INTO ' . $table . ' ' . $query;
+ if (!$this->db->queryF($query)) {
+ if (!isset($this->f_tables['insert'][$table])) {
+ $this->f_tables['insert'][$table] = 1;
+ } else {
+ $this->f_tables['insert'][$table]++;
+ }
+ return false;
+ } else {
+ if (!isset($this->s_tables['insert'][$table])) {
+ $this->s_tables['insert'][$table] = 1;
+ } else {
+ $this->s_tables['insert'][$table]++;
+ }
+ return $this->db->getInsertId();
+ }
+ }
+
+ /**
+ * @return bool
+ */
+ public function isError()
+ {
+ return (isset($this->f_tables)) ? true : false;
+ }
+
+ /**
+ * @param $tables
+ *
+ * @return array
+ */
+ public function deleteTables($tables)
+ {
+ $deleted = array();
+ $this->db->connect();
+ foreach ($tables as $key => $val) {
+ if (!$this->db->query("DROP TABLE " . $this->db->prefix($key))) {
+ $deleted[] = $val;
+ }
+ }
+ return $deleted;
+ }
+
+ /**
+ * @param $table
+ *
+ * @return bool
+ */
+ public function tableExists($table)
+ {
+ $table = trim($table);
+ $ret = false;
+ if ($table != '') {
+ $this->db->connect();
+ $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix($table);
+ $ret = (false != $this->db->query($sql)) ? true : false;
+ }
+ return $ret;
+ }
+
+ /**
+ * This method allows to copy fields from one table to another
+ *
+ * @param array $fieldsMap Map of the fields
+ * ex: array('oldfieldname' => 'newfieldname');
+ * @param string $oTableName Old Table
+ * @param string $nTableName New Table
+ * @param bool $dropTable Drop old Table
+ */
+ public function copyFields($fieldsMap, $oTableName, $nTableName, $dropTable = false)
+ {
+ $sql = "SHOW COLUMNS FROM " . $this->db->prefix($oTableName);
+ $result = $this->db->queryF($sql);
+ if (($rows = $this->db->getRowsNum($result)) == count($fieldsMap)) {
+ $sql = "SELECT * FROM " . $this->db->prefix($oTableName);
+ $result = $this->db->queryF($sql);
+ while ($myrow = $this->db->fetchArray($result)) {
+ ksort($fieldsMap);
+ ksort($myrow);
+ $sql = "INSERT INTO `" . $this->db->prefix($nTableName) . "` " . "(`" . implode("`,`", $fieldsMap) . "`)" . " VALUES ('" . implode("','", $myrow) . "')";
+
+ $this->db->queryF($sql);
+ }
+ if ($dropTable) {
+ $sql = "DROP TABLE " . $this->db->prefix($oTableName);
+ $this->db->queryF($sql);
+ }
+ }
+ }
}
\ No newline at end of file
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabase.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabase.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabase.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -36,6 +36,11 @@
{
/**
+ * @var object keep track of last result since we need it for getAffectedRows
+ */
+ private $_lastResult;
+
+ /**
* connect to the database
*
* @param bool $selectdb select the database now?
@@ -45,36 +50,24 @@
{
static $db_charset_set;
- if (!extension_loaded('mysql')) {
- trigger_error('notrace:mysql extension not loaded', E_USER_ERROR);
- return false;
- }
+ $config = new \Doctrine\DBAL\Configuration();
+ $connectionParams = array(
+ 'dbname' => XOOPS_DB_NAME,
+ 'user' => XOOPS_DB_USER,
+ 'password' => XOOPS_DB_PASS,
+ 'host' => XOOPS_DB_HOST,
+// 'port' => ?,
+// 'unix_socket' => ?,
+ 'charset' => XOOPS_DB_CHARSET,
+ 'driver' => 'pdo_mysql'
+ );
+ $this->conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
- $this->allowWebChanges = ($_SERVER['REQUEST_METHOD'] != 'GET');
-
- if (XOOPS_DB_PCONNECT == 1) {
- $this->conn = @mysql_pconnect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
- } else {
- $this->conn = @mysql_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS);
- }
-
if (!$this->conn) {
$xoopsPreload = XoopsPreload::getInstance();
$xoopsPreload->triggerEvent('core.database.noconn', array($this));
return false;
}
- if ($selectdb != false) {
- if (!mysql_select_db(XOOPS_DB_NAME)) {
- $xoopsPreload = XoopsPreload::getInstance();
- $xoopsPreload->triggerEvent('core.database.nodb');
- return false;
- }
- }
- if (!isset($db_charset_set) && defined('XOOPS_DB_CHARSET') && XOOPS_DB_CHARSET) {
- $this->queryF("SET NAMES '" . XOOPS_DB_CHARSET . "'");
- }
- $db_charset_set = 1;
- $this->queryF("SET SQL_BIG_SELECTS = 1");
return true;
}
@@ -100,7 +93,7 @@
*/
public function fetchRow($result)
{
- return @mysql_fetch_row($result);
+ return $result->fetch(\PDO::FETCH_NUM);
}
/**
@@ -111,7 +104,7 @@
*/
public function fetchArray($result)
{
- return @mysql_fetch_assoc($result);
+ return $result->fetch(\PDO::FETCH_ASSOC);
}
/**
@@ -122,7 +115,7 @@
*/
public function fetchBoth($result)
{
- return @mysql_fetch_array($result, MYSQL_BOTH);
+ return $result->fetch(\PDO::FETCH_BOTH);
}
/**
@@ -133,7 +126,7 @@
*/
public function fetchObject($result)
{
- return @mysql_fetch_object($result);
+ return $result->fetch(\PDO::FETCH_OBJ);
}
/**
@@ -143,7 +136,7 @@
*/
public function getInsertId()
{
- return mysql_insert_id($this->conn);
+ return $this->conn->lastInsertId();
}
/**
@@ -154,7 +147,7 @@
*/
public function getRowsNum($result)
{
- return @mysql_num_rows($result);
+ return $result->rowCount();
}
/**
@@ -164,7 +157,7 @@
*/
public function getAffectedRows()
{
- return mysql_affected_rows($this->conn);
+ return $this->_lastResult->rowCount();
}
/**
@@ -174,7 +167,7 @@
*/
public function close()
{
- mysql_close($this->conn);
+ $this->conn->close();
}
/**
@@ -185,7 +178,7 @@
*/
public function freeRecordSet($result)
{
- return mysql_free_result($result);
+ return $result->closeCursor();
}
/**
@@ -195,7 +188,7 @@
*/
public function error()
{
- return @mysql_error();
+ return $this->conn->errorInfo();
}
/**
@@ -205,7 +198,7 @@
*/
public function errno()
{
- return @mysql_errno();
+ return $this->conn->errorCode();
}
/**
@@ -227,7 +220,7 @@
*/
public function quote($string)
{
- return "'" . str_replace("\\\"", '"', str_replace("\\"", '"', mysql_real_escape_string($string, $this->conn))) . "'";
+ return $this->conn->quote($string);
}
/**
@@ -249,7 +242,8 @@
}
$xoopsPreload = XoopsPreload::getInstance();
$xoopsPreload->triggerEvent('core.database.query.start');
- $result = mysql_query($sql, $this->conn);
+ $result = $this->conn->query($sql);
+ $this->_lastResult = $result;
$xoopsPreload->triggerEvent('core.database.query.end');
if ($result) {
@@ -303,25 +297,36 @@
/**
* Get field name
*
+ * @deprecated Names are available as keys when using fetchArray
+ *
* @param resource $result query result
* @param int $offset numerical field index
* @return string
*/
public function getFieldName($result, $offset)
{
- return mysql_field_name($result, $offset);
+ $xoops = Xoops::getInstance();
+ $xoops->deprecated('getFieldName() is deprecated. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__);
+
+ return null;
}
/**
* Get field type
*
+ * @deprecated Field types should be know from the XoopsObject or
+ * schema, not from the result set.
+ *
* @param resource $result query result
* @param int $offset numerical field index
* @return string
*/
public function getFieldType($result, $offset)
{
- return mysql_field_type($result, $offset);
+ $xoops = Xoops::getInstance();
+ $xoops->deprecated('getFieldType() is deprecated. See how to replace it in file ' . __FILE__ . ' line ' . __LINE__);
+
+ return null;
}
/**
@@ -332,8 +337,19 @@
*/
public function getFieldsNum($result)
{
- return mysql_num_fields($result);
+ return $result->columnCount();
}
+
+ /**
+ * Return the connection object, a Doctrine\DBAL\Connection
+ *
+ * @return object Doctrine\DBAL\Connection
+ */
+ public function direct()
+ {
+ return $this->conn;
+ }
+
}
/**
Added: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/xoopsdatabase.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/xoopsdatabase.php (rev 0)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/xoopsdatabase.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -0,0 +1,38 @@
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
+/**
+ * MySQL access
+ *
+ * @copyright The XOOPS project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package class
+ * @subpackage database
+ * @since 1.0.0
+ * @author Kazumi Ono <on...@xo...>
+ * @version $Id: mysqldatabase.php 10328 2012-12-07 00:56:07Z trabis $
+ */
+
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+/**
+ * connection to a mysql database
+ *
+ * @abstract
+ * @author Kazumi Ono <on...@xo...>
+ * @copyright copyright (c) 2000-2003 XOOPS.org
+ * @package class
+ * @subpackage database
+ */
+class XoopsConnection extends Doctrine\DBAL\Connection
+{
+
+}
\ No newline at end of file
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xml/rpc/xoopsapi.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xml/rpc/xoopsapi.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xml/rpc/xoopsapi.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -313,12 +313,13 @@
function getCategories($respond=true)
{
+ global $xoopsDB;
if (!$this->_checkUser($this->params[1], $this->params[2])) {
$this->response->add(new XoopsXmlRpcFault(104));
} else {
include_once XOOPS_ROOT_PATH.'/class/xoopstopic.php';
- $this->db = XoopsDatabaseFactory::getDatabaseConnection();
- $xt = new XoopsTopic($db->prefix('topics'));
+ //$this->db = xoopsDB;
+ $xt = new XoopsTopic($xoopsDB->prefix('topics'));
$ret = $xt->getTopicsList();
if (!$respond) {
return $ret;
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopslists.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopslists.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopslists.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -662,7 +662,8 @@
*/
static function getUserRankList()
{
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ global $xoopsDB;
+ $db = $xoopsDB;
$myts = MyTextSanitizer::getInstance();
$sql = sprintf('SELECT rank_id, rank_title FROM ' . $db->prefix('ranks') . ' WHERE rank_special = %u', 1);
$ret = array();
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopsload.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopsload.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopsload.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -510,4 +510,5 @@
if (!defined('XOOPS_AUTOLOAD')) {
define('XOOPS_AUTOLOAD', true);
spl_autoload_register(array('XoopsLoad', 'load'));
+ require XOOPS_PATH . '/vendor/autoload.php';
}
\ No newline at end of file
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/include/common.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/include/common.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/include/common.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -91,9 +91,10 @@
/**
* Get database for making it global
+ * Will also setup $xoopsDB for legacy support.
* Requires XOOPS_DB_PROXY;
*/
-$xoopsDB = $xoops->db();
+ $xoops->db();
/**
* Get xoops configs
* Requires functions and database loaded
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/block.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/block.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/block.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -408,9 +408,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'newblocks', 'XoopsBlock', 'bid', 'name');
}
@@ -513,7 +513,8 @@
*/
public function getAllBlocksByGroup($groupid, $asobject = true, $side = null, $visible = null, $orderby = "b.weight,b.bid", $isactive = 1)
{
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ global $xoopsDB;
+ $db = $xoopsDB;
$ret = array();
if (!$asobject) {
$sql = 'SELECT b.bid ';
@@ -574,7 +575,8 @@
*/
public function getAllBlocks($rettype = "object", $side = null, $visible = null, $orderby = "side,weight,bid", $isactive = 1)
{
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ global $xoopsDB;
+ $db = $xoopsDB;
$ret = array();
$where_query = " WHERE isactive=" . $isactive;
if (isset($side)) {
@@ -629,8 +631,9 @@
*/
public function getByModule($moduleid, $asobject = true)
{
+ global $xoopsDB;
$moduleid = intval($moduleid);
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ $db = $xoopsDB;
if ($asobject == true) {
$sql = "SELECT * FROM " . $db->prefix("newblocks") . " WHERE mid=" . $moduleid;
} else {
@@ -661,8 +664,9 @@
*/
public function getAllByGroupModule($groupid, $module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)
{
+ global $xoopsDB;
$isactive = intval($isactive);
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ $db = $xoopsDB;
$ret = array();
$blockids = array();
$sqlgroupid="";
@@ -737,7 +741,8 @@
*/
public function getNonGroupedBlocks($module_id = 0, $toponlyblock = false, $visible = null, $orderby = 'b.weight, m.block_id', $isactive = 1)
{
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ global $xoopsDB;
+ $db = $xoopsDB;
$ret = array();
$bids = array();
$sql = "SELECT DISTINCT(bid) from " . $db->prefix('newblocks');
@@ -799,13 +804,14 @@
*/
public function countSimilarBlocks($moduleId, $funcNum, $showFunc = null)
{
+ global $xoopsDB;
$funcNum = intval($funcNum);
$moduleId = intval($moduleId);
if ($funcNum < 1 || $moduleId < 1) {
// invalid query
return 0;
}
- $db = XoopsDatabaseFactory::getDatabaseConnection();
+ $db = $xoopsDB;
if (isset($showFunc)) {
// showFunc is set for more strict comparison
$sql = sprintf("SELECT COUNT(*) FROM %s WHERE mid = %d AND func_num = %d AND show_func = %s", $db->prefix('newblocks'), $moduleId, $funcNum, $db->quoteString(trim($showFunc)));
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/blockmodulelink.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/blockmodulelink.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/blockmodulelink.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -38,9 +38,9 @@
class XoopsBlockmodulelinkHandler extends XoopsPersistableObjectHandler
{
/**
- * @param null|XoopsDatabase $db
+ * @param null|XoopsConnection $db
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'block_module_link', 'XoopsBlockmodulelink', 'block_id', 'module_id');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/cachemodel.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/cachemodel.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/cachemodel.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -47,9 +47,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'cache_model', 'XoopsCachemodelObject', 'cache_key', 'cache_data');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configcategory.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configcategory.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configcategory.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -94,9 +94,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'configcategory', 'XoopsConfigCategory', 'confcat_id', 'confcat_name');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configitem.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configitem.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configitem.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -267,9 +267,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'config', 'XoopsConfigItem', 'conf_id', 'conf_name');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configoption.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configoption.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/configoption.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -103,9 +103,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'configoption', 'XoopsConfigOption', 'confop_id', 'confop_name');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/group.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/group.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/group.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -100,9 +100,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'groups', 'XoopsGroup', 'groupid', 'name');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/groupperm.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/groupperm.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/groupperm.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -115,9 +115,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'group_permission', 'XoopsGroupPerm', 'gperm_id', 'gperm_name');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/member.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/member.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/member.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -64,7 +64,7 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db
+ * @param XoopsConnection|null $db
*/
public function __construct($db = null)
{
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/membership.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/membership.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/membership.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -54,9 +54,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'groups_users_link', 'XoopsMembership', 'linkid', 'groupid');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/module.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/module.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/module.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -426,9 +426,9 @@
/**
* Constructor
*
- * @param XoopsDatabase|null $db {@link XoopsDatabase}
+ * @param XoopsConnection|null $db {@link XoopsConnection}
*/
- public function __construct(XoopsDatabase $db = null)
+ public function __construct(XoopsConnection $db = null)
{
parent::__construct($db, 'modules', 'XoopsModule', 'mid', 'dirname');
}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/object.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/object.php 2013-08-20 15:17:05 UTC (rev 11953)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/kernel/object.php 2013-08-20 17:12:12 UTC (rev 11954)
@@ -1,1117 +1,1117 @@
-<?php
-/**
- * XOOPS Kernel Object
- *
- * You may not change or alter any portion of this comment or credits
- * of supporting developers from this source code or any supporting source code
- * which is considered copyrighted (c) material of the original comment or credit authors.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package kernel
- * @since 2.0.0
- * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
- * @author Taiwen Jiang <ph...@us...>
- * @version $Id$
- */
-
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-/**
- * *#@+
- * Xoops object datatype
- */
-define('XOBJ_DTYPE_TXTBOX', 1);
-define('XOBJ_DTYPE_TXTAREA', 2);
-define('XOBJ_DTYPE_INT', 3);
-define('XOBJ_...
[truncated message content] |