|
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[...
[truncated message content] |
|
From: <red...@us...> - 2013-08-25 20:44:30
|
Revision: 11978
http://sourceforge.net/p/xoops/svn/11978
Author: redheadedrod
Date: 2013-08-25 20:44:25 +0000 (Sun, 25 Aug 2013)
Log Message:
-----------
Changes to files in directory to bring to PSR2 minus namespace.
@package and @category reflect the name of the file minus the extension and capitalized as the class is.
xoopsload.php - added legacy classes to loader list
Xoops/Auth/Xoops.php - changed parameter back to xoopsdatabase.
mysqldatabaseproxy.php & mysqldatabasesafe.php new class files for PSR2.
database/databasefactory.php - fixed bug in connection configuration.
rest were solely PSR2 changes and moving to "official" header.
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/connection.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/database.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/database/querybuilder.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/sqlutility.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/xoopsload.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/xoops_lib/Xoops/Auth/Xoops.php
Added Paths:
-----------
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabaseproxy.php
XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabasesafe.php
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/connection.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/connection.php 2013-08-25 20:43:23 UTC (rev 11977)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/connection.php 2013-08-25 20:44:25 UTC (rev 11978)
@@ -1,68 +1,61 @@
<?php
/**
- * Connection wrapper for Doctrine DBAL Connection
- *
- * 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.
- *
- * @category Xoops\Class\Database\XoopsConnection
- * @package Class
- * @subpackage Database
- * @author readheadedrod <red...@ho...>
- * @author Richard Griffith <ri...@ge...>
- * @copyright 2013 The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @version $Id: connection.php 10328 2012-12-07 00:56:07Z trabis $
- * @link http://xoops.org
- * @since 1.0
+ 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.
*/
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
/**
* Connection wrapper for Doctrine DBAL Connection
*
- * @category Xoops\Database\XoopsConnection
- * @package Xoops
+ * PHP version 5.3
+ *
+ * @category Xoops\Database\Connection
+ * @package Connection
* @author readheadedrod <red...@ho...>
* @author Richard Griffith <ri...@ge...>
* @copyright 2013 The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @version Release: 1.0
+ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @version Release: 2.6
* @link http://xoops.org
- * @since 1.0
+ * @since 2.6.0
*/
class XoopsConnection extends \Doctrine\DBAL\Connection
{
- private $_safe = true;
+ /**
+ * @var bool $safe true means it is safe to update pages or write to database
+ * removed allowedWebChanges as unnecessary. Using this instead.
+ */
+ private $safe = true;
- private $_allowedWebChanges = true;
+ /**
+ * @var bool $force true means force SQL even if safe is not true.
+ */
+ private $force = false;
+
/**
* Initializes a new instance of the Connection class.
*
- * This sets up necissary variables before calling parent constructor
+ * This sets up necessary variables before calling parent constructor
*
* @param array $params Parameters for the driver
* @param Driver $driver The driver to use
* @param Configuration $config The connection configuration
* @param EventManager $eventManager Event manager to use
*/
- public function __construct(array $params,
+ public function __construct(
+ array $params,
\Doctrine\DBAL\Driver\PDOMySql\Driver $driver,
\Doctrine\DBAL\Configuration $config = null,
\Doctrine\Common\EventManager $eventManager = null
) {
- // Not sure if this next line does anything
- $this->allowWebChanges = ($_SERVER['REQUEST_METHOD'] != 'GET');
- if (!defined('XOOPS_DB_PROXY')) {
+ if (!defined('XOOPS_DB_PROXY') || ($_SERVER['REQUEST_METHOD'] != 'GET')) {
$this->safe = true;
} else {
$this->safe = false;
@@ -120,11 +113,8 @@
*
* @return integer The number of affected rows.
*/
- public function updatePrefix($tableName,
- array $data,
- array $identifier,
- array $types = array()
- ) {
+ public function updatePrefix($tableName, array $data, array $identifier, array $types = array())
+ {
$tableName = $this->prefix($tableName);
return $this->update($tableName, $data, $identifier, $types);
}
@@ -162,12 +152,8 @@
$xoopsPreload = XoopsPreload::getInstance();
$xoopsPreload->triggerEvent('core.database.query.start');
try {
- $result = call_user_func_array(
- array('parent', 'query'),
- func_get_args()
- );
- }
- catch (Exception $e) {
+ $result = call_user_func_array(array('parent', 'query'), func_get_args());
+ } catch (Exception $e) {
$result=false;
}
/* if(is_object($result)) {
@@ -176,16 +162,10 @@
$xoopsPreload->triggerEvent('core.database.query.end');
if ($result) {
- $xoopsPreload->triggerEvent(
- 'core.database.query.success',
- (array($sql))
- );
+ $xoopsPreload->triggerEvent('core.database.query.success', (array($sql)));
return $result;
} else {
- $xoopsPreload->triggerEvent(
- 'core.database.query.failure',
- (array($sql, $this))
- );
+ $xoopsPreload->triggerEvent('core.database.query.failure', (array($sql, $this)));
return false;
}
}
@@ -202,9 +182,7 @@
return call_user_func_array(array($this, "queryForce"), func_get_args());
} else {
$sql = ltrim(func_get_arg(0));
- if (!$this->allowedWebChanges
- && strtolower(substr($sql, 0, 6))!= 'select'
- ) {
+ if (!$this->safe && strtolower(substr($sql, 0, 6))!= 'select') {
//trigger_error('Database updates are not allowed
//during processing of a GET request', E_USER_WARNING);
//needs to be replaced with standard error
@@ -252,5 +230,4 @@
{
return new XoopsQueryBuilder($this);
}
-
-}
\ No newline at end of file
+}
Modified: XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/database.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/database.php 2013-08-25 20:43:23 UTC (rev 11977)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/database.php 2013-08-25 20:44:25 UTC (rev 11978)
@@ -1,44 +1,31 @@
<?php
/**
- * Abstract base class for XOOPS Database access classes
- *
- * 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.
+ 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.
- *
- * @category Xoops\Class\Database\Database
- * @package Class
- * @subpackage Database
- * @author Kazumi Ono <on...@xo...>
- * @copyright 2013 The XOOPS project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @version $Id$
- * @link http://xoops.org
- * @since 1.0.0
+ 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.
*/
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
/**
* Abstract base class for Database access classes
*
-
+ * PHP version 5.3
+ *
* @category Xoops\Class\Database\Database
- * @package Class
- * @subpackage Database
+ * @package Database
* @author Kazumi Ono <on...@xo...>
* @copyright 2013 The XOOPS project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @version Release:2.6
* @link http://xoops.org
- * @since 1.0.0
+ * @since 2.6.0
* @abstract
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
*/
-abstract class XoopsDatabase // Depreciated with 2.6
+abstract class XoopsDatabase
{
/**
* Database connection
@@ -68,6 +55,7 @@
* @param string $value table prefix
*
* @return this does not return a value
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
*/
public function setPrefix($value)
{
@@ -75,12 +63,15 @@
}
/**
+ * public function prefix($tablename = '')
+ *
* attach the prefix.'_' to a given tablename
* if tablename is empty, only prefix will be returned
*
* @param string $tablename tablename
*
* @return string prefixed tablename, just prefix if tablename is empty
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
*/
public function prefix($tablename = '')
{
@@ -98,10 +89,11 @@
* @param bool $selectdb select the database now?
*
* @return bool successful?
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
+ *
*/
- abstract function connect($selectdb = true);
+ abstract public function connect($selectdb = true);
/**
* generate an ID for a new row
@@ -112,10 +104,10 @@
* @param string $sequence name of the sequence from which to get the next ID
*
* @return int always 0, because mysql has support for autoincrement
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function genId($sequence);
+ abstract public function genId($sequence);
/**
* Get a result row as an enumerated array
@@ -123,10 +115,10 @@
* @param resource $result resource to get result from
*
* @return array
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function fetchRow($result);
+ abstract public function fetchRow($result);
/**
* Fetch a result row as an associative array
@@ -134,10 +126,10 @@
* @param resource $result resource to get result from
*
* @return array
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function fetchArray($result);
+ abstract public function fetchArray($result);
/**
* Fetch a result row as an associative array
@@ -145,9 +137,10 @@
* @param resource $result resource to get result from
*
* @return array
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
+ * @abstract
*/
- abstract function fetchBoth($result);
+ abstract public function fetchBoth($result);
/**
* Fetch a result row as an object
@@ -155,19 +148,19 @@
* @param resource $result resource to get result from
*
* @return object|stdClass
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function fetchObject($result);
+ abstract public function fetchObject($result);
/**
* Get the ID generated from the previous INSERT operation
*
* @return int
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function getInsertId();
+ abstract public function getInsertId();
/**
* Get number of rows in result
@@ -175,28 +168,28 @@
* @param resource $result the resource containing the number of rows
*
* @return int the number of rows to return
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function getRowsNum($result);
+ abstract public function getRowsNum($result);
/**
* Get number of affected rows
*
* @return int
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function getAffectedRows();
+ abstract public function getAffectedRows();
/**
* Close MySQL connection
*
* @return void
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function close();
+ abstract public function close();
/**
* Free all memory associated with the result identifier result.
@@ -204,20 +197,20 @@
* @param resource $result query result
*
* @return bool TRUE on success or FALSE on failure.
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function freeRecordSet($result);
+ abstract public function freeRecordSet($result);
/**
* Returns the text of the error message from previous MySQL operation
*
* @return bool Returns the error text from the last MySQL function,
* or '' (the empty string) if no error occurred.
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function error();
+ abstract public function error();
/**
* Returns the numerical value of the error message from previous
@@ -225,10 +218,10 @@
*
* @return int Returns the error number from the last MySQL function
* , or 0 (zero) if no error occurred.
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function errno();
+ abstract public function errno();
/**
* Returns escaped string text with single
@@ -237,10 +230,10 @@
* @param string $str unescaped string text
*
* @return string escaped string text with single quotes around
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function quoteString($str);
+ abstract public function quoteString($str);
/**
* Quotes a string for use in a query.
@@ -248,10 +241,10 @@
* @param string $string string to quote
*
* @return string
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function quote($string);
+ abstract public function quote($string);
/**
* perform a query on the database
@@ -262,10 +255,10 @@
*
* @return bool|resource query result or FALSE if successful
* or TRUE if successful and no result
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function queryF($sql, $limit = 0, $start = 0);
+ abstract public function queryF($sql, $limit = 0, $start = 0);
/**
* perform a query
@@ -278,10 +271,10 @@
* @param int $start offset of first record to return
*
* @return this returns nothing
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function query($sql, $limit = 0, $start = 0);
+ abstract public function query($sql, $limit = 0, $start = 0);
/**
* perform queries from SQL dump file in a batch
@@ -293,7 +286,7 @@
* @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
- abstract function queryFromFile($file);
+ abstract public function queryFromFile($file);
/**
* Get field name
@@ -302,10 +295,10 @@
* @param int $offset numerical field index
*
* @return string
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function getFieldName($result, $offset);
+ abstract public function getFieldName($result, $offset);
/**
* Get field type
@@ -314,10 +307,10 @@
* @param int $offset numerical field index
*
* @return string
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function getFieldType($result, $offset);
+ abstract public function getFieldType($result, $offset);
/**
* Get number of fields in result
@@ -325,8 +318,8 @@
* @param resource $result query result
*
* @return int
- * @deprecated since version 2.6.0 - alpha 3
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
* @abstract
*/
- abstract function getFieldsNum($result);
+ abstract public function getFieldsNum($result);
}
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-25 20:43:23 UTC (rev 11977)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/databasefactory.php 2013-08-25 20:44:25 UTC (rev 11978)
@@ -1,39 +1,28 @@
<?php
/**
- * Factory Class for XOOPS Database
- *
- * 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.
- *
- * @category Xoops\Class\Database\Xoopsdatabasefactory
- * @package Class
- * @subpackage Database
- * @author Kazumi Ono <on...@xo...>
- * @copyright 2013 The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @version $Id$
- * @link http://xoops.org
- * @since 1.0
+ 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.
*/
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
/**
- * XoopsDatabaseFactory
+ * XoopsDatabaseFactory class
*
- * @category Xoops\Class\Database\Xoopsdatabasefactory
- * @package Kernel
- * @author Kazumi Ono <on...@xo...>
- * @access public
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @link http://xoops.org
- * @since 1.0
+ * PHP version 5.3
+ *
+ * @category Xoops\Class\Database\Databasefactory
+ * @package DatabaseFactory
+ * @author Kazumi Ono <on...@xo...>
+ * @author readheadedrod <red...@ho...>
+ * @copyright 2013 The XOOPS project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @version Release:2.6
+ * @link http://xoops.org
+ * @since 2.6.0
*/
class XoopsDatabaseFactory
@@ -53,7 +42,7 @@
*
* @return XoopsDatabase Reference to the only instance of database class
*/
- static function getDatabaseConnection()
+ public static function getDatabaseConnection()
{
global $xoopsDB;
static $instance;
@@ -70,7 +59,7 @@
'charset' => XOOPS_DB_CHARSET,
'driver' => 'pdo_mysql',
'wrapperClass' => 'XoopsConnection',
- 'driverOptions' => ''
+ 'driverOptions' => array('')
);
$instance
= \Doctrine\DBAL\DriverManager::getConnection(
@@ -108,9 +97,11 @@
*
* @static
* @staticvar XoopsDatabase The only instance of database class
+ *
* @return XoopsDatabase Reference to the only instance of database class
+ * @depreciated do not use for anything. Will be removed when dependencies are removed from installer.
*/
- static function getDatabase()
+ public static function getDatabase()
{
static $database;
if (!isset($database)) {
@@ -127,11 +118,7 @@
unset($database);
$database = new $class();
} else {
- trigger_error(
- 'notrace:Failed to load database of type: ' . XOOPS_DB_TYPE
- . ' in file: ' . __FILE__ . ' at line '
- . __LINE__, E_USER_WARNING
- );
+ trigger_error('notrace:Database Failed in file: ' . __FILE__ . ' at line ' . __LINE__, E_USER_WARNING);
}
}
return $database;
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-25 20:43:23 UTC (rev 11977)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/manager.php 2013-08-25 20:44:25 UTC (rev 11978)
@@ -1,41 +1,27 @@
<?php
/**
- * Database manager for XOOPS
- *
- * 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.
+ 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.
- *
- * @category Xoops\Class\Database\Manager
- * @package Class
- * @subpackage Database
- * @author Haruki Setoyama <ha...@pl...>
- * @copyright 2013 The XOOPS project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @version $Id$
- * @link http://xoops.org
- * @since 1.0.0
+ 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.
*/
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
/**
* Database manager for XOOPS
*
- * @category Xoops\Class\Database\Manager
- * @package Class
- * @subpackage Database
- * @author Haruki Setoyama <ha...@pl...>
- * @copyright 2013 The XOOPS project http://sourceforge.net/projects/xoops/
- * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @link http://xoops.org
- * @since 1.0.0
- * @abstract
+ * PHP version 5.3
+ *
+ * @category Xoops\Class\Database\Manager
+ * @package Manager
+ * @author Haruki Setoyama <ha...@pl...>
+ * @copyright 2013 The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @version Release: 2.6
+ * @link http://xoops.org
+ * @since 2.6.0
*/
class XoopsDatabaseManager
@@ -43,12 +29,12 @@
/**
* @var array
*/
- private $_s_tables = array();
+ private $s_tables = array();
/**
* @var array
*/
- private $_f_tables = array();
+ private $f_tables = array();
/**
* @var XoopsDatabase
@@ -392,4 +378,4 @@
}
}
}
-}
\ 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-25 20:43:23 UTC (rev 11977)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabase.php 2013-08-25 20:44:25 UTC (rev 11978)
@@ -1,42 +1,32 @@
<?php
/**
- * MySQL access
+ 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.
+ */
+
+/**
+ * connection to a mysql database - legacy support only
*
- * 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.
+ * PHP version 5.3
*
- * @category Xoops\Class\Database\XoopsMySQLDatabase
- * @package Class
- * @subpackage Database
+ * @category Xoops\Class\Database\MySQLDatabase
+ * @package MySQLDatabase
* @author Kazumi Ono <on...@xo...>
- * @copyright 2013 The XOOPS project http://sourceforge.net/projects/xoops/
- * @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @version $Id$
+ * @author readheadedrod <red...@ho...>
+ * @author Richard Griffith <ri...@ge...>
+ * @copyright 2013 The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
+ * @version Release: 2.6
* @link http://xoops.org
- * @since 1.0
+ * @since 2.6.0
+ * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
*
*/
-
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-/**
- * connection to a mysql database
- *
- * @category Xoops\Class\Database\MySQLDatabase
- * @package Xoops
- * @author readheadedrod <red...@ho...>
- * @author Richard Griffith <ri...@ge...>
- * @copyright 2013 The XOOPS Project http://sourceforge.net/projects/xoops/
- * @license http://www.fsf.org/copyleft/gpl.html GNU public license
- * @version Release: 1.0
- * @link http://xoops.org
- * @since 1.0
- */
class XoopsMySQLDatabase extends XoopsDatabase
{
@@ -52,21 +42,21 @@
*
* @var resource
*/
- private $_lastResult;
+ private $lastResult;
/**
* Database c...
[truncated message content] |