|
From: <red...@us...> - 2013-08-24 23:41:27
|
Revision: 11976
http://sourceforge.net/p/xoops/svn/11976
Author: redheadedrod
Date: 2013-08-24 23:41:24 +0000 (Sat, 24 Aug 2013)
Log Message:
-----------
Updated all files in the class/database directory. Some had wrong EOL on them. They now pass PHP code sniffer with just a couple warnings.
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
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-24 22:35:00 UTC (rev 11975)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/connection.php 2013-08-24 23:41:24 UTC (rev 11976)
@@ -1,14 +1,28 @@
<?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.
+/**
+ * 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
+ */
- 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');
/**
@@ -16,7 +30,7 @@
*
* @category Xoops\Database\XoopsConnection
* @package Xoops
- * @author readheadedrod
+ * @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
@@ -26,17 +40,28 @@
*/
class XoopsConnection extends \Doctrine\DBAL\Connection
{
- private $safe = true;
+ private $_safe = true;
- public $allowedWebChanges = true;
+ private $_allowedWebChanges = true;
+
+ /**
+ * Initializes a new instance of the Connection class.
+ *
+ * This sets up necissary 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,
- \Doctrine\DBAL\Driver\PDOMySql\Driver $driver,
- \Doctrine\DBAL\Configuration $config = null,
- \Doctrine\Common\EventManager $eventManager = null)
- {
- // $this->prefix = XOOPS_DB_PREFIX;
- //$this->allowWebChanges = ($_SERVER['REQUEST_METHOD'] != 'GET');
+ \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')) {
$this->safe = true;
} else {
@@ -69,14 +94,15 @@
* Adds prefix to the name of the table then passes to normal function.
*
* @param string $tableName The name of the table to insert data into.
- * @param array $data An associative array containing column-value pairs.
- * @param array $types Types of the inserted data.
+ * @param array $data An associative array containing column-value pairs.
+ * @param array $types Types of the inserted data.
+ *
* @return integer The number of affected rows.
*/
public function insertPrefix($tableName, array $data, array $types = array())
{
- $tableName = $this->prefix($tableName);
- return $this->insert($tableName, $data, $types);
+ $tableName = $this->prefix($tableName);
+ return $this->insert($tableName, $data, $types);
}
@@ -85,14 +111,20 @@
*
* Adds prefix to the name of the table then passes to normal function.
*
- * @param string $tableName The name of the table to update.
- * @param array $data
- * @param array $identifier The update criteria. An associative array containing column-value pairs.
- * @param array $types Types of the merged $data and $identifier arrays in that order.
+ * @param string $tableName The name of the table to update.
+ * @param array $data The data to update
+ * @param array $identifier The update criteria.
+ * An associative array containing column-value pairs.
+ * @param array $types Types of the merged $data and
+ * $identifier arrays in that order.
+ *
* @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);
}
@@ -103,8 +135,10 @@
*
* Adds prefix to the name of the table then passes to normal function.
*
- * @param string $tableName The name of the table on which to delete.
- * @param array $identifier The deletion criteria. An associative array containing column-value pairs.
+ * @param string $tableName The name of the table on which to delete.
+ * @param array $identifier The deletion criteria.
+ * An associative array containing column-value pairs.
+ *
* @return integer The number of affected rows.
*/
public function deletePrefix($tableName, array $identifier)
@@ -117,8 +151,8 @@
/**
* perform a query on the database
+ * Always performs query and triggers timer to time it
*
- * @param string $sql a valid MySQL query
* @return bool|resource query result or FALSE if not successful
* or TRUE if successful and no result
*/
@@ -128,33 +162,39 @@
$xoopsPreload = XoopsPreload::getInstance();
$xoopsPreload->triggerEvent('core.database.query.start');
try {
- $result = call_user_func_array(array('parent', 'query'), func_get_args());
+ $result = call_user_func_array(
+ array('parent', 'query'),
+ func_get_args()
+ );
}
catch (Exception $e) {
$result=false;
}
- /* if(is_object($result)) {
- $this->_lastResult = clone $result; // Has to be clone or it is reference.
- } */
+ /* if(is_object($result)) {
+ $this->_lastResult = clone $result;
+ } */ // Remove if not using getAffectedRows
$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;
}
}
/**
- * perform a query
+ * perform a safe query if allowed
+ * can receive variable number of arguments
*
- * This method is empty and does nothing! It should therefore only be
- * used if nothing is exactly what you want done! ;-)
- *
- * @param string $sql a valid MySQL query
- * @abstract
+ * @return returns the value received from queryForce
*/
public function query()
{
@@ -162,8 +202,12 @@
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') {
- //trigger_error('Database updates are not allowed during processing of a GET request', E_USER_WARNING);
+ if (!$this->allowedWebChanges
+ && 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
return false;
}
return call_user_func_array(array($this, "queryForce"), func_get_args());
@@ -174,7 +218,9 @@
* perform queries from SQL dump file in a batch
*
* @param string $file file path to an SQL dump file
- * @return bool FALSE if failed reading SQL file or TRUE if the file has been read and queries executed
+ *
+ * @return bool FALSE if failed reading SQL file or
+ * TRUE if the file has been read and queries executed
*/
public function queryFromFile($file)
{
@@ -184,7 +230,10 @@
foreach ($pieces as $query) {
// [0] contains the prefixed query
// [4] contains unprefixed table name
- $prefixed_query = SqlUtility::prefixQuery(trim($query), $this->prefix());
+ $prefixed_query = SqlUtility::prefixQuery(
+ trim($query),
+ $this->prefix()
+ );
if ($prefixed_query != false) {
$this->query($prefixed_query[0]);
}
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-24 22:35:00 UTC (rev 11975)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/database.php 2013-08-24 23:41:24 UTC (rev 11976)
@@ -1,24 +1,25 @@
<?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.
-*/
-
/**
* Abstract base class for XOOPS Database access classes
*
- * @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$
+ * 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
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -26,12 +27,18 @@
/**
* Abstract base class for Database access classes
*
+
+ * @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)
+ * @link http://xoops.org
+ * @since 1.0.0
* @abstract
- * @author Kazumi Ono <on...@xo...>
- * @package kernel
- * @subpackage database
*/
-abstract class XoopsDatabase
+abstract class XoopsDatabase // Depreciated with 2.6
{
/**
* Database connection
@@ -59,6 +66,8 @@
* set the prefix for tables in the database
*
* @param string $value table prefix
+ *
+ * @return this does not return a value
*/
public function setPrefix($value)
{
@@ -75,6 +84,7 @@
*/
public function prefix($tablename = '')
{
+
if ($tablename != '') {
return $this->prefix . '_' . $tablename;
} else {
@@ -83,148 +93,240 @@
}
/**
- * @abstract
+ * connect to the database
*
- * @param bool $selectdb
+ * @param bool $selectdb select the database now?
*
- * @return void
+ * @return bool successful?
+ * @deprecated since version 2.6.0 - alpha 3
+ * @abstract
*/
abstract function connect($selectdb = true);
/**
- * @param $sequence
+ * generate an ID for a new row
*
+ * This is for compatibility only. Will always return 0, because MySQL supports
+ * autoincrement for primary keys.
+ *
+ * @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
* @abstract
*/
abstract function genId($sequence);
/**
- * @param $result
+ * Get a result row as an enumerated array
*
+ * @param resource $result resource to get result from
+ *
+ * @return array
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function fetchRow($result);
/**
- * @param $result
+ * Fetch a result row as an associative array
*
+ * @param resource $result resource to get result from
+ *
* @return array
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function fetchArray($result);
/**
- * @param $result
+ * Fetch a result row as an associative array
*
- * @abstract
+ * @param resource $result resource to get result from
+ *
+ * @return array
+ * @deprecated since version 2.6.0 - alpha 3
*/
abstract function fetchBoth($result);
/**
- * @param $result
+ * Fetch a result row as an object
*
+ * @param resource $result resource to get result from
+ *
+ * @return object|stdClass
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function fetchObject($result);
/**
+ * Get the ID generated from the previous INSERT operation
+ *
+ * @return int
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function getInsertId();
/**
- * @param $result
+ * Get number of rows in result
*
+ * @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
* @abstract
*/
abstract function getRowsNum($result);
/**
+ * Get number of affected rows
+ *
+ * @return int
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function getAffectedRows();
/**
+ * Close MySQL connection
+ *
+ * @return void
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function close();
/**
- * @param $result
+ * Free all memory associated with the result identifier result.
*
+ * @param resource $result query result
+ *
+ * @return bool TRUE on success or FALSE on failure.
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract 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
* @abstract
*/
abstract function error();
/**
+ * Returns the numerical value of the error message from previous
+ * MySQL operation
+ *
+ * @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
* @abstract
*/
abstract function errno();
/**
- * @param $str
+ * Returns escaped string text with single
+ * quotes around it to be safely stored in database
*
+ * @param string $str unescaped string text
+ *
+ * @return string escaped string text with single quotes around
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function quoteString($str);
/**
- * @param $string
+ * Quotes a string for use in a query.
*
+ * @param string $string string to quote
+ *
+ * @return string
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function quote($string);
/**
- * @param $sql
- * @param int $limit
- * @param int $start
+ * perform a query on the database
*
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ *
+ * @return bool|resource query result or FALSE if successful
+ * or TRUE if successful and no result
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function queryF($sql, $limit = 0, $start = 0);
/**
- * @param $sql
- * @param int $limit
- * @param int $start
+ * perform a query
*
+ * This method is empty and does nothing! It should therefore only be
+ * used if nothing is exactly what you want done! ;-)
+ *
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ *
+ * @return this returns nothing
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function query($sql, $limit = 0, $start = 0);
/**
- * @param $file
+ * perform queries from SQL dump file in a batch
*
+ * @param string $file file path to an SQL dump file
+ *
+ * @return bool FALSE if failed reading SQL file or TRUE
+ * if the file has been read and queries executed
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function queryFromFile($file);
/**
- * @param $result
- * @param $offset
+ * Get field name
*
+ * @param resource $result query result
+ * @param int $offset numerical field index
+ *
+ * @return string
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function getFieldName($result, $offset);
/**
- * @param $result
- * @param $offset
+ * Get field type
*
+ * @param resource $result query result
+ * @param int $offset numerical field index
+ *
+ * @return string
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function getFieldType($result, $offset);
/**
- * @param $result
+ * Get number of fields in result
*
+ * @param resource $result query result
+ *
+ * @return int
+ * @deprecated since version 2.6.0 - alpha 3
* @abstract
*/
abstract function getFieldsNum($result);
-}
\ No newline at end of file
+}
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-24 22:35:00 UTC (rev 11975)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/databasefactory.php 2013-08-24 23:41:24 UTC (rev 11976)
@@ -1,22 +1,25 @@
<?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.
-*/
-
/**
* Factory Class for XOOPS Database
*
- * @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
- * @version $Id$
+ * 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
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -24,9 +27,13 @@
/**
* XoopsDatabaseFactory
*
- * @package Kernel
- * @author Kazumi Ono <on...@xo...>
- * @access public
+ * @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
*/
class XoopsDatabaseFactory
@@ -43,6 +50,7 @@
*
* @static
* @staticvar XoopsDatabase The only instance of database class
+ *
* @return XoopsDatabase Reference to the only instance of database class
*/
static function getDatabaseConnection()
@@ -57,26 +65,31 @@
'user' => XOOPS_DB_USER,
'password' => XOOPS_DB_PASS,
'host' => XOOPS_DB_HOST,
-// 'port' => ?,
-// 'unix_socket' => ?,
+ 'port' => '',
+ 'unix_socket' => '',
'charset' => XOOPS_DB_CHARSET,
'driver' => 'pdo_mysql',
'wrapperClass' => 'XoopsConnection',
- // 'driverOptions' => array (PDO::ATTR_PERSISTENT => TRUE)
- // this is how you call them but not compatible with doctrine.
-
+ 'driverOptions' => ''
);
- $instance = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
+ $instance
+ = \Doctrine\DBAL\DriverManager::getConnection(
+ $connectionParams,
+ $config
+ );
// Legacy support
- if (isset($instance)) {
- require_once XOOPS_ROOT_PATH . '/class/database/mysqldatabase.php';
+ if (isset($instance)) {
+ include_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));
+ $xoopsPreload->triggerEvent(
+ 'core.class.database.databasefactory.connection',
+ array(&$class)
+ );
$xoopsDB = new $class();
$xoopsDB->setPrefix(XOOPS_DB_PREFIX);
$xoopsDB->conn = $instance;
@@ -86,27 +99,9 @@
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 */
- /* $instance = new $class();
- $instance->setPrefix(XOOPS_DB_PREFIX);
- if (!$instance->connect()) {
- trigger_error('notrace:Unable to connect to database', E_USER_ERROR);
- }
- }
- return $instance;
- } */
-
/**
* Gets a reference to the only instance of database class. Currently
* only being used within the installer.
@@ -119,7 +114,10 @@
{
static $database;
if (!isset($database)) {
- if (XoopsLoad::fileExists($file = XOOPS_ROOT_PATH . '/class/database/' . XOOPS_DB_TYPE . 'database.php')) {
+ if (XoopsLoad::fileExists(
+ $file = XOOPS_ROOT_PATH . '/class/database/'
+ . XOOPS_DB_TYPE . 'database.php'
+ )) {
include_once $file;
if (!defined('XOOPS_DB_PROXY')) {
$class = 'Xoops' . ucfirst(XOOPS_DB_TYPE) . 'DatabaseSafe';
@@ -129,9 +127,13 @@
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:Failed to load database of type: ' . XOOPS_DB_TYPE
+ . ' in file: ' . __FILE__ . ' at line '
+ . __LINE__, E_USER_WARNING
+ );
}
}
return $database;
}
-}
\ No newline at end of file
+}
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-24 22:35:00 UTC (rev 11975)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/manager.php 2013-08-24 23:41:24 UTC (rev 11976)
@@ -1,24 +1,41 @@
<?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.
+/**
+ * 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.
- 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.
-*/
+ * 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
+ */
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
/**
* 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$
+ * @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
*/
class XoopsDatabaseManager
@@ -26,12 +43,12 @@
/**
* @var array
*/
- private $s_tables = array();
+ private $_s_tables = array();
/**
* @var array
*/
- private $f_tables = array();
+ private $_f_tables = array();
/**
* @var XoopsDatabase
@@ -49,7 +66,7 @@
public $failureStrings = array();
/**
- *
+ *Construct declaration
*/
public function __construct()
{
@@ -73,7 +90,9 @@
}
/**
- * @return bool
+ * Is the database connectable?
+ *
+ * @return bool is it connectable?
*/
public function isConnectable()
{
@@ -81,7 +100,9 @@
}
/**
- * @return bool
+ * Checks if a database exists
+ *
+ * @return bool returns if exists
*/
public function dbExists()
{
@@ -89,7 +110,9 @@
}
/**
- * @return bool
+ * creates a database table
+ *
+ * @return bool return if successful
*/
public function createDB()
{
@@ -101,9 +124,11 @@
}
/**
- * @param string $sql_file_path
- * @param bool $force
+ * Loads a query from a file
*
+ * @param string $sql_file_path name of file to read
+ * @param bool $force weither to force the query or not
+ *
* @return bool
*/
public function queryFromFile($sql_file_path, $force = false)
@@ -179,6 +204,8 @@
}
/**
+ * returns a report
+ *
* @return string
*/
public function report()
@@ -189,7 +216,9 @@
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 .= ($cmd != 'insert')
+ ? sprintf($this->successStrings[$cmd], $key)
+ : sprintf($this->successStrings[$cmd], $val, $key);
$content .= "</li>\n";
}
}
@@ -198,7 +227,9 @@
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 .= ($cmd != 'insert')
+ ? sprintf($this->failureStrings[$cmd], $key)
+ : sprintf($this->failureStrings[$cmd], $val, $key);
$content .= "</li>\n";
}
}
@@ -208,8 +239,10 @@
}
/**
- * @param string $sql
+ * runs a query
*
+ * @param string $sql sql statement to perform
+ *
* @return mixed
*/
public function query($sql)
@@ -219,9 +252,11 @@
}
/**
- * @param $table
+ * Setup prefix table
*
- * @return string
+ * @param string $table table to prefix
+ *
+ * @return string prefixed table
*/
public function prefix($table)
{
@@ -230,9 +265,11 @@
}
/**
- * @param $ret
+ * fetches an array
*
- * @return array
+ * @param string $ret resource that was returned from query
+ *
+ * @return array returns the array
*/
public function fetchArray($ret)
{
@@ -241,9 +278,11 @@
}
/**
- * @param $table
- * @param $query
+ * Inserts into a table
*
+ * @param string $table table to insert into
+ * @param string $query query to use to insert
+ *
* @return bool|void
*/
public function insert($table, $query)
@@ -269,6 +308,8 @@
}
/**
+ * return the error
+ *
* @return bool
*/
public function isError()
@@ -277,9 +318,11 @@
}
/**
- * @param $tables
+ * Deletes tables
*
- * @return array
+ * @param string $tables table to delete
+ *
+ * @return array list of dropped tables
*/
public function deleteTables($tables)
{
@@ -294,9 +337,11 @@
}
/**
- * @param $table
+ * Checks to see if table exists
*
- * @return bool
+ * @param string $table name of database table looking for
+ *
+ * @return bool true if exists or false if doesnt
*/
public function tableExists($table)
{
@@ -318,9 +363,15 @@
* @param string $oTableName Old Table
* @param string $nTableName New Table
* @param bool $dropTable Drop old Table
+ *
+ * @return this does not return anything
*/
- public function copyFields($fieldsMap, $oTableName, $nTableName, $dropTable = false)
- {
+ 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)) {
@@ -329,7 +380,9 @@
while ($myrow = $this->db->fetchArray($result)) {
ksort($fieldsMap);
ksort($myrow);
- $sql = "INSERT INTO `" . $this->db->prefix($nTableName) . "` " . "(`" . implode("`,`", $fieldsMap) . "`)" . " VALUES ('" . implode("','", $myrow) . "')";
+ $sql = "INSERT INTO `" . $this->db->prefix($nTableName)
+ . "` " . "(`" . implode("`,`", $fieldsMap) . "`)" .
+ " VALUES ('" . implode("','", $myrow) . "')";
$this->db->queryF($sql);
}
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-24 22:35:00 UTC (rev 11975)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/mysqldatabase.php 2013-08-24 23:41:24 UTC (rev 11976)
@@ -1,25 +1,25 @@
<?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$
+ * 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\XoopsMySQLDatabase
+ * @package Class
+ * @subpackage Database
+ * @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$
+ * @link http://xoops.org
+ * @since 1.0
+ *
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
@@ -27,10 +27,15 @@
/**
* connection to a mysql database
*
- * @author Kazumi Ono <on...@xo...>
- * @copyright copyright (c) 2000-2003 XOOPS.org
- * @package class
- * @subpackage 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
{
@@ -61,7 +66,7 @@
*
* @var resource
*/
- public $_selectdb;
+ private $_selectdb;
@@ -70,7 +75,9 @@
* connect to the database
*
* @param bool $selectdb select the database now?
+ *
* @return bool successful?
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function connect($selectdb = true)
{
@@ -88,7 +95,9 @@
* autoincrement for primary keys.
*
* @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
*/
public function genId($sequence)
{
@@ -98,13 +107,14 @@
/**
* Get a result row as an enumerated array
*
- * @param resource $result
+ * @param resource $result resource to get result from
+ *
* @return array
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function fetchRow($result)
{
- if(!is_object($result))
- {
+ if (!is_object($result)) {
return null;
}
return $result->fetch(\PDO::FETCH_NUM);
@@ -113,13 +123,14 @@
/**
* Fetch a result row as an associative array
*
- * @param resource $result
+ * @param resource $result resource to get result from
+ *
* @return array
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function fetchArray($result)
{
- if(!is_object($result))
- {
+ if (!is_object($result)) {
return null;
}
return $result->fetch(\PDO::FETCH_ASSOC);
@@ -128,28 +139,30 @@
/**
* Fetch a result row as an associative array
*
- * @param resource $result
+ * @param resource $result resource to get result from
+ *
* @return array
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function fetchBoth($result)
{
- if(!is_object($result))
- {
+ if (!is_object($result)) {
return null;
}
return $result->fetch(\PDO::FETCH_BOTH);
}
/**
- * XoopsMySQLDatabase::fetchObjected()
+ * Fetch a result row as an object
*
- * @param resource $result
+ * @param resource $result resource to get result from
+ *
* @return object|stdClass
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function fetchObject($result)
{
- if(!is_object($result))
- {
+ if (!is_object($result)) {
return null;
}
return $result->fetch(\PDO::FETCH_OBJ);
@@ -159,6 +172,7 @@
* Get the ID generated from the previous INSERT operation
*
* @return int
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function getInsertId()
{
@@ -168,8 +182,10 @@
/**
* Get number of rows in result
*
- * @param resource $result
- * @return int
+ * @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
*/
public function getRowsNum($result)
{
@@ -180,11 +196,11 @@
* Get number of affected rows
*
* @return int
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function getAffectedRows()
{
- if(!is_object($this->_lastResult))
- {
+ if (!is_object($this->_lastResult)) {
return null;
}
return $this->_lastResult->rowCount();
@@ -194,6 +210,7 @@
* Close MySQL connection
*
* @return void
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function close()
{
@@ -204,7 +221,9 @@
* will free all memory associated with the result identifier result.
*
* @param resource $result query result
+ *
* @return bool TRUE on success or FALSE on failure.
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function freeRecordSet($result)
{
@@ -214,7 +233,9 @@
/**
* 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.
+ * @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
*/
public function error()
{
@@ -222,9 +243,12 @@
}
/**
- * Returns the numerical value of the error message from previous MySQL operation
+ * Returns the numerical value of the error message from previous
+ * MySQL operation
*
- * @return int Returns the error number from the last MySQL function, or 0 (zero) if no error occurred.
+ * @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
*/
public function errno()
{
@@ -232,10 +256,13 @@
}
/**
- * Returns escaped string text with single quotes around it to be safely stored in database
+ * Returns escaped string text with single
+ * quotes around it to be safely stored in database
*
* @param string $str unescaped string text
+ *
* @return string escaped string text with single quotes around
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function quoteString($str)
{
@@ -245,24 +272,34 @@
/**
* Quotes a string for use in a query.
*
- * @param $string
+ * @param string $string string to quote
+ *
* @return string
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function quote($string)
{
//return $this->conn->quote($string);
//There was a reason for this longer command but can't recall what it was...
- return str_replace("\\\"", '"', str_replace("\\"", '"', $this->conn->quote($string)));
+ return str_replace(
+ "\\\"", '"', str_replace(
+ "\\"",
+ '"',
+ $this->conn->quote($string)
+ )
+ );
}
/**
* perform a query on the database
*
- * @param string $sql a valid MySQL query
- * @param int $limit number of records to return
- * @param int $start offset of first record to return
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ *
* @return bool|resource query result or FALSE if successful
* or TRUE if successful and no result
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function queryF($sql, $limit = 0, $start = 0)
{
@@ -280,16 +317,21 @@
catch (Exception $e) {
$result=false;
}
- if(is_object($result)) {
- $this->_lastResult = clone $result; // Has to be clone or it is reference.
+ if (is_object($result)) {
+ // Has to be clone or it is reference.
+ $this->_lastResult = clone $result;
}
$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;
}
}
@@ -300,10 +342,12 @@
* This method is empty and does nothing! It should therefore only be
* used if nothing is exactly what you want done! ;-)
*
- * @param string $sql a valid MySQL query
- * @param int $limit number of records to return
- * @param int $start offset of first record to return
- * @abstract
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ *
+ * @return this returns nothing
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function query($sql, $limit = 0, $start = 0)
{
@@ -313,7 +357,10 @@
* perform queries from SQL dump file in a batch
*
* @param string $file file path to an SQL dump file
- * @return bool FALSE if failed reading SQL file or TRUE if the file has been read and queries executed
+ *
+ * @return bool FALSE if failed reading SQL file or TRUE
+ * if the file has been read and queries executed
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function queryFromFile($file)
{
@@ -323,7 +370,8 @@
foreach ($pieces as $query) {
// [0] contains the prefixed query
// [4] contains unprefixed table name
- $prefixed_query = SqlUtility::prefixQuery(trim($query), $this->prefix());
+ $prefixed_query
+ = SqlUtility::prefixQuery(trim($query), $this->prefix());
if ($prefixed_query != false) {
$this->query($prefixed_query[0]);
}
@@ -336,11 +384,11 @@
/**
* Get field name
*
- * @deprecated Names are available as keys when using fetchArray
+ * @param resource $result query result
+ * @param int $offset numerical field index
*
- * @param resource $result query result
- * @param int $offset numerical field index
* @return string
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function getFieldName($result, $offset)
{
@@ -359,12 +407,11 @@
/**
* 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
*
- * @param resource $result query result
- * @param int $offset numerical field index
* @return string
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function getFieldType($result, $offset)
{
@@ -375,8 +422,27 @@
$temp = (string)(
((($t == 'STRING') || ($t == 'VAR_STRING') ) ? 'string' : '' ) .
- ( (in_array($t, array('TINY', 'SHORT', 'LONG', 'LONGLONG', 'INT24'))) ? 'int' : '' ) .
- ( (in_array($t, array('FLOAT', 'DOUBLE', 'DECIMAL', 'NEWDECIMAL'))) ? 'real' : '' ) .
+ ( (
+ in_array(
+ $t, array(
+ 'TINY',
+ 'SHORT',
+ 'LONG',
+ 'LONGLONG',
+ 'INT24')
+ )
+ )
+ ? 'int' : '' ) .
+ ( (
+ in_array(
+ $t, array(
+ 'FLOAT',
+ 'DOUBLE',
+ 'DECIMAL',
+ 'NEWDECIMAL')
+ )
+ )
+ ? 'real' : '' ) .
( ($t == 'TIMESTAMP') ? 'timestamp' : '' ) .
( ($t == 'YEAR') ? 'year' : '') .
( (($t == 'DATE') || ($t == 'NEWDATE') ) ? 'date' : '' ) .
@@ -385,7 +451,16 @@
( ($t == 'ENUM') ? 'enum' : '' ) .
( ($t == 'GEOMETRY') ? 'geometry' : '' ) .
( ($t == 'DATETIME') ? 'datetime' : '' ) .
- ( (in_array($t, array('TINY_BLOB', 'BLOB', 'MEDIUM_BLOB', 'LONG_BLOB'))) ? 'blob' : '' ) .
+ ( (
+ in_array(
+ $t, array(
+ 'TINY_BLOB',
+ 'BLOB',
+ 'MEDIUM_BLOB',
+ 'LONG_BLOB' )
+ )
+ )
+ ? 'blob' : '' ) .
( ($t == 'NULL') ? 'null' : '' )
);
return $temp;
@@ -400,44 +475,41 @@
* Get number of fields in result
*
* @param resource $result query result
+ *
* @return int
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function getFieldsNum($result)
{
return $result->columnCount();
}
-
- /**
- * Return the connection object, a Doctrine\DBAL\Connection
- *
- * @return object Doctrine\DBAL\Connection
- */
- /* not needed
- public function direct()
- {
- return $this->conn;
- }
- */
}
/**
* Safe Connection to a MySQL database.
*
- * @author Kazumi Ono <on...@xo...>
- * @copyright copyright (c) 2000-2003 XOOPS.org
- * @package kernel
- * @subpackage database
+ * @category Xoops\Class\Database\XoopsMySQLDatabaseSafe
+ * @package Class
+ * @subpackage Database
+ * @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
+ * @link http://xoops.org
+ * @since 1.0
+ * @deprecated since version 2.6.0 - alpha 3
*/
class XoopsMySQLDatabaseSafe extends XoopsMySQLDatabase
{
/**
* perform a query on the database
*
- * @param string $sql a valid MySQL query
- * @param int $limit number of records to return
- * @param int $start offset of first record to return
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ *
* @return resource query result or FALSE if successful
* or TRUE if successful and no result
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function query($sql, $limit = 0, $start = 0)
{
@@ -449,12 +521,17 @@
* Read-Only connection to a MySQL database.
*
* This class allows only SELECT queries to be performed through its
- * {@link query()} method for security reasons.
+ * query() method for security reasons.
*
- * @author Kazumi Ono <on...@xo...>
- * @copyright copyright (c) 2000-2003 XOOPS.org
- * @package kernel
- * @subpackage database
+ * @category Xoops\Class\Database\XoopsMySQLDatabaseProxy
+ * @package Class
+ * @subpackage Database
+ * @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
+ * @link http://xoops.org
+ * @since 1.0
+ * @deprecated since version 2.6.0 - alpha 3
*/
class XoopsMySQLDatabaseProxy extends XoopsMySQLDatabase
{
@@ -463,18 +540,24 @@
*
* this method allows only SELECT queries for safety.
*
- * @param string $sql a valid MySQL query
- * @param int $limit number of records to return
- * @param int $start offset of first record to return
+ * @param string $sql a valid MySQL query
+ * @param int $limit number of records to return
+ * @param int $start offset of first record to return
+ *
* @return resource query result or FALSE if unsuccessful
+ * @deprecated since version 2.6.0 - alpha 3
*/
public function query($sql, $limit = 0, $start = 0)
{
$sql = ltrim($sql);
if (!$this->allowWebChanges && strtolower(substr($sql, 0, 6)) != 'select') {
- trigger_error('Database updates are not allowed during processing of a GET request', E_USER_WARNING);
+ trigger_error(
+ 'Database updates are not allowed'
+ .'during processing of a GET request',
+ E_USER_WARNING
+ );
return false;
}
return $this->queryF($sql, $limit, $start);
}
-}
\ No newline at end of file
+}
Modified: 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/querybuilder.php 2013-08-24 22:35:00 UTC (rev 11975)
+++ XoopsCore/branches/2.6.x/2.6.0_doctrine/htdocs/class/database/querybuilder.php 2013-08-24 23:41:24 UTC (rev 11976)
@@ -1,190 +1,203 @@
-<?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.
-*/
-
-defined('XOOPS_ROOT_PATH') or die('Restricted access');
-
-/**
- * Connection wrapper for Doctrine DBAL Connection
- *
- * @category Xoops\Database\XoopsConnection
- * @package Xoops
- * @author readheadedrod
- * @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 XoopsQueryBuilder extends \Doctrine\DBAL\Query\QueryBuilder
-{
-
-
- public function __construct(\Doctrine\DBAL\Connection $connection)
- {
- $this->prefix = XOOPS_DB_PREFIX;
- parent::__construct($connection);
- }
-
-
- /**
- * Turns the query being built into a bulk delete query that ranges over
- * a certain table.
- *
- * <code>
- * $qb = $conn->createQueryBuilder()
- * ->delete('users', 'u')
- * ->where('u.id = :user_id');
- * ->setParameter(':user_id', 1);
- * </code>
- *
- * @param string $delete The table whose rows are subject to the deletion. Adds table prefix.
- * @param string $alias The table alias used in the constructed query.
- * @return QueryBuilder This QueryBuilder instance.
- */
- public function deletePrefix($delete = null, $alias = null)
- {
- $delete = XoopsConnection::prefix($delete);
- return $this->delete($delete, $alias);
- }
-
- /**
- * Turns the query being built into a bulk update query that ranges over
- * a certain table
- *
- * <code>
- * $qb = $conn->createQueryBuilder()
- * ->update('users', 'u')
- * ->set('u.password', md5('password'))
- * ->where('u.id = ?');
- * </code>
- *
- * @param string $update The table whose rows are subject to the update. Adds table prefix.
- * @param string $alias The table alias used in the constructed query.
- * @return QueryBuilder This QueryBuilder instance.
- */
- public function updatePrefix($update = null, $alias = null)
- {
- $update = XoopsConnection::prefix($update);
- return $this->update($update, $alias);
- }
-
- /**
- * Create and add a query root corresponding to the table identified by the
- * given alias, forming a cartesian product with any existing query roots.
- *
- * <code>
- * $qb = $conn->createQueryBuilder()
- * ->select('u.id')
- * ->from('users', 'u')
- * </code>
- *
- * @param string $from The table. Adds table prefix.
- * @param string $alias The alias of the table
- * @return QueryBuilder This QueryBuilder instance.
- */
- public function fromPrefix($from, $alias)
- {
- $from = XoopsConnection::prefix($from);
- return $this->from($from, $alias);
- }
-
- /**
- * Creates and adds a join to the query.
- *
- * <code>
- * $qb = $conn->createQueryBuilder()
- * ->select('u.name')
- * ->from('users', 'u')
- * ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
- * </code>
- *
- * @param string $fromAlias The alias that points to a from clause
- * @param string $join The table name to join. Adds table prefix.
- * @param string $alias The alias of the join table
- * @param string $condition The condition for the join
- * @return QueryBuilder This QueryBuilder instance.
- */
- publi...
[truncated message content] |