Joomla! PHP Cross Reference Web Portals

Source: /libraries/joomla/database/database.php - 173 lines - 5148 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * @package     Joomla.Platform
   4   * @subpackage  Database
   5   *
   6   * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   7   * @license     GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  defined('JPATH_PLATFORM') or die;
  11  
  12  /**
  13   * Database connector class.
  14   *
  15   * @package     Joomla.Platform
  16   * @subpackage  Database
  17   * @since       11.1
  18   * @deprecated  13.1
  19   */
  20  abstract class JDatabase
  21  {
  22      /**
  23       * Execute the SQL statement.
  24       *
  25       * @return  mixed  A database cursor resource on success, boolean false on failure.
  26       *
  27       * @since   11.1
  28       * @throws  RuntimeException
  29       */
  30  	public function query()
  31      {
  32          JLog::add('JDatabase::query() is deprecated, use JDatabaseDriver::execute() instead.', JLog::WARNING, 'deprecated');
  33  
  34          return $this->execute();
  35      }
  36  
  37      /**
  38       * Get a list of available database connectors.  The list will only be populated with connectors that both
  39       * the class exists and the static test method returns true.  This gives us the ability to have a multitude
  40       * of connector classes that are self-aware as to whether or not they are able to be used on a given system.
  41       *
  42       * @return  array  An array of available database connectors.
  43       *
  44       * @since   11.1
  45       * @deprecated  13.1
  46       */
  47  	public static function getConnectors()
  48      {
  49          JLog::add('JDatabase::getConnectors() is deprecated, use JDatabaseDriver::getConnectors() instead.', JLog::WARNING, 'deprecated');
  50  
  51          return JDatabaseDriver::getConnectors();
  52      }
  53  
  54      /**
  55       * Gets the error message from the database connection.
  56       *
  57       * @param   boolean  $escaped  True to escape the message string for use in JavaScript.
  58       *
  59       * @return  string  The error message for the most recent query.
  60       *
  61       * @deprecated  12.1
  62       * @since   11.1
  63       */
  64  	public function getErrorMsg($escaped = false)
  65      {
  66          JLog::add('JDatabase::getErrorMsg() is deprecated, use exception handling instead.', JLog::WARNING, 'deprecated');
  67  
  68          if ($escaped)
  69          {
  70              return addslashes($this->errorMsg);
  71          }
  72          else
  73          {
  74              return $this->errorMsg;
  75          }
  76      }
  77  
  78      /**
  79       * Gets the error number from the database connection.
  80       *
  81       * @return      integer  The error number for the most recent query.
  82       *
  83       * @since       11.1
  84       * @deprecated  12.1
  85       */
  86  	public function getErrorNum()
  87      {
  88          JLog::add('JDatabase::getErrorNum() is deprecated, use exception handling instead.', JLog::WARNING, 'deprecated');
  89  
  90          return $this->errorNum;
  91      }
  92  
  93      /**
  94       * Method to return a JDatabaseDriver instance based on the given options.  There are three global options and then
  95       * the rest are specific to the database driver.  The 'driver' option defines which JDatabaseDriver class is
  96       * used for the connection -- the default is 'mysqli'.  The 'database' option determines which database is to
  97       * be used for the connection.  The 'select' option determines whether the connector should automatically select
  98       * the chosen database.
  99       *
 100       * Instances are unique to the given options and new objects are only created when a unique options array is
 101       * passed into the method.  This ensures that we don't end up with unnecessary database connection resources.
 102       *
 103       * @param   array  $options  Parameters to be passed to the database driver.
 104       *
 105       * @return  JDatabaseDriver  A database object.
 106       *
 107       * @since       11.1
 108       * @deprecated  13.1
 109       */
 110  	public static function getInstance($options = array())
 111      {
 112          JLog::add('JDatabase::getInstance() is deprecated, use JDatabaseDriver::getInstance() instead.', JLog::WARNING, 'deprecated');
 113  
 114          return JDatabaseDriver::getInstance($options);
 115      }
 116  
 117      /**
 118       * Splits a string of multiple queries into an array of individual queries.
 119       *
 120       * @param   string  $sql  Input SQL string with which to split into individual queries.
 121       *
 122       * @return  array  The queries from the input string separated into an array.
 123       *
 124       * @since   11.1
 125       * @deprecated  13.1
 126       */
 127  	public static function splitSql($sql)
 128      {
 129          JLog::add('JDatabase::splitSql() is deprecated, use JDatabaseDriver::splitSql() instead.', JLog::WARNING, 'deprecated');
 130  
 131          return JDatabaseDriver::splitSql($sql);
 132      }
 133  
 134      /**
 135       * Return the most recent error message for the database connector.
 136       *
 137       * @param   boolean  $showSQL  True to display the SQL statement sent to the database as well as the error.
 138       *
 139       * @return  string  The error message for the most recent query.
 140       *
 141       * @since   11.1
 142       * @deprecated  12.1
 143       */
 144  	public function stderr($showSQL = false)
 145      {
 146          JLog::add('JDatabase::stderr() is deprecated.', JLog::WARNING, 'deprecated');
 147  
 148          if ($this->errorNum != 0)
 149          {
 150              return JText::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $this->errorNum, $this->errorMsg)
 151              . ($showSQL ? "<br />SQL = <pre>$this->sql</pre>" : '');
 152          }
 153          else
 154          {
 155              return JText::_('JLIB_DATABASE_FUNCTION_NOERROR');
 156          }
 157      }
 158  
 159      /**
 160       * Test to see if the connector is available.
 161       *
 162       * @return  boolean  True on success, false otherwise.
 163       *
 164       * @since   11.1
 165       * @deprecated  12.3 Use JDatabaseDriver::isSupported() instead.
 166       */
 167  	public static function test()
 168      {
 169          JLog::add('JDatabase::test() is deprecated. Use JDatabaseDriver::isSupported() instead.', JLog::WARNING, 'deprecated');
 170  
 171          return static::isSupported();
 172      }
 173  }

title

Description

title

Description

title

Description

title

title

Body