Ver Mensaje Individual
  #7 (permalink)  
Antiguo 05/03/2015, 12:06
abarranco_7
 
Fecha de Ingreso: marzo-2015
Mensajes: 6
Antigüedad: 9 años, 2 meses
Puntos: 0
Respuesta: Error de Linea

Este es el código original, lo adjunto en dos partes

<?php
/**
* @package Joomla.Platform
* @subpackage Database
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_PLATFORM') or die;

/**
* MySQL database driver supporting PDO based connections
*
* @package Joomla.Platform
* @subpackage Database
* @see http://php.net/manual/en/ref.pdo-mysql.php
* @since 3.4
*/
class JDatabaseDriverPdomysql extends JDatabaseDriverPdo
{
/**
* The name of the database driver.
*
* @var string
* @since 3.4
*/
public $name = 'pdomysql';

/**
* The character(s) used to quote SQL statement names such as table names or field names,
* etc. The child classes should define this as necessary. If a single character string the
* same character is used for both sides of the quoted name, else the first character will be
* used for the opening quote and the second for the closing quote.
*
* @var string
* @since 3.4
*/
protected $nameQuote = '`';

/**
* The null or zero representation of a timestamp for the database driver. This should be
* defined in child classes to hold the appropriate value for the engine.
*
* @var string
* @since 3.4
*/
protected $nullDate = '0000-00-00 00:00:00';

/**
* The minimum supported database version.
*
* @var string
* @since 3.4
*/
protected static $dbMinimum = '5.0.4';

/**
* Constructor.
*
* @param array $options Array of database options with keys: host, user, password, database, select.
*
* @since 3.4
*/
public function __construct($options)
{
// Get some basic values from the options.
$options['driver'] = 'mysql';
$options['charset'] = (isset($options['charset'])) ? $options['charset'] : 'utf8';

$this->charset = $options['charset'];

// Finalize initialisation.
parent::__construct($options);
}

/**
* Connects to the database if needed.
*
* @return void Returns void if the database connected successfully.
*
* @since 3.4
* @throws RuntimeException
*/
public function connect()
{
parent::connect();

$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
}

/**
* Test to see if the MySQL connector is available.
*
* @return boolean True on success, false otherwise.
*
* @since 3.4
*/
public static function isSupported()
{
return in_array('mysql', PDO::getAvailableDrivers());
}

/**
* Drops a table from the database.
*
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must exist before it is dropped.
*
* @return JDatabaseDriverPdomysql Returns this object to support chaining.
*
* @since 3.4
* @throws RuntimeException
*/
public function dropTable($tableName, $ifExists = true)
{
$this->connect();

$query = $this->getQuery(true);

$query->setQuery('DROP TABLE ' . ($ifExists ? 'IF EXISTS ' : '') . $this->quoteName($tableName));

$this->setQuery($query);

$this->execute();

return $this;
}

/**
* Select a database for use.
*
* @param string $database The name of the database to select for use.
*
* @return boolean True if the database was successfully selected.
*
* @since 3.4
* @throws RuntimeException
*/
public function select($database)
{
$this->connect();

$this->setQuery('USE ' . $this->quoteName($database));

$this->execute();

return $this;
}

/**
* Method to get the database collation in use by sampling a text field of a table in the database.
*
* @return mixed The collation in use by the database (string) or boolean false if not supported.
*
* @since 3.4
* @throws RuntimeException
*/
public function getCollation()
{
$this->connect();

// Attempt to get the database collation by accessing the server system variable.
$this->setQuery('SHOW VARIABLES LIKE "collation_database"');
$result = $this->loadObject();

if (property_exists($result, 'Value'))
{
return $result->Value;
}
else
{
return false;
}
}

/**
* Shows the table CREATE statement that creates the given tables.
*
* @param mixed $tables A table name or a list of table names.
*
* @return array A list of the create SQL for the tables.
*
* @since 3.4
* @throws RuntimeException
*/
public function getTableCreate($tables)
{
$this->connect();

// Initialise variables.
$result = array();

// Sanitize input to an array and iterate over the list.
settype($tables, 'array');

foreach ($tables as $table)
{
$this->setQuery('SHOW CREATE TABLE ' . $this->quoteName($table));

$row = $this->loadRow();

// Populate the result array based on the create statements.
$result[$table] = $row[1];
}

return $result;
}

/**
* Retrieves field information about a given table.
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
*
* @return array An array of fields for the database table.
*
* @since 3.4
* @throws RuntimeException
*/
public function getTableColumns($table, $typeOnly = true)
{
$this->connect();

$result = array();

// Set the query to get the table fields statement.
$this->setQuery('SHOW FULL COLUMNS FROM ' . $this->quoteName($table));

$fields = $this->loadObjectList();

// If we only want the type as the value add just that to the list.
if ($typeOnly)
{
foreach ($fields as $field)
{
$result[$field->Field] = preg_replace("/[(0-9)]/", '', $field->Type);
}
}