Vergleich inc/db_pdo.php - 1.8.3 - 1.8.23

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 13Zeile 13
	/**
* The database class to store PDO objects
*

	/**
* The database class to store PDO objects
*

	 * @var object

	 * @var PDO

	 */
public $db;

/**
* The last query resource that ran
*

	 */
public $db;

/**
* The last query resource that ran
*

	 * @var object

	 * @var PDOStatement

	 */
public $last_query = "";


	 */
public $last_query = "";


Zeile 31Zeile 31
	/**
* Connect to the database.
*

	/**
* Connect to the database.
*

	 * @param string The database DSN.
* @param string The database username. (depends on DSN)
* @param string The database user's password. (depends on DSN)
* @param array The databases driver options (optional)
* @return boolean True on success

	 * @param string $dsn The database DSN.
* @param string $username The database username. (depends on DSN)
* @param string $password The database user's password. (depends on DSN)
* @param array $driver_options The databases driver options (optional)


	 */
function __construct($dsn, $username="", $password="", $driver_options=array())
{
try
{

	 */
function __construct($dsn, $username="", $password="", $driver_options=array())
{
try
{

    		$this->db = new PDO($dsn, $user, $password, $driver_options);

			$this->db = new PDO($dsn, $username, $password, $driver_options);

		}
catch(PDOException $exception)
{

		}
catch(PDOException $exception)
{

Zeile 49Zeile 48
		}

$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

		}

$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


return true;

 
	}

/**
* Query the database.
*

	}

/**
* Query the database.
*

	 * @param string The query SQL.
* @return resource The query data.

	 * @param string $string The query SQL.
* @return PDOStatement The query data.

	 */
function query($string)
{

	 */
function query($string)
{

Zeile 74Zeile 71
	/**
* Return a result array for a query.
*

	/**
* Return a result array for a query.
*

	 * @param resource The query resource.


	 * @param PDOStatement $query The query resource.
* @param int $resulttype One of PDO's constants: FETCH_ASSOC, FETCH_BOUND, FETCH_CLASS, FETCH_INTO, FETCH_LAZY, FETCH_NAMED, FETCH_NUM, FETCH_OBJ or FETCH_BOTH

	 * @return array The array of results.
*/

	 * @return array The array of results.
*/

	function fetch_array($query)

	function fetch_array($query, $resulttype=PDO::FETCH_BOTH)

	{

	{

		if(!is_object($query))

		switch($resulttype)

		{

		{

			return;












			case PDO::FETCH_ASSOC:
case PDO::FETCH_BOUND:
case PDO::FETCH_CLASS:
case PDO::FETCH_INTO:
case PDO::FETCH_LAZY:
case PDO::FETCH_NAMED:
case PDO::FETCH_NUM:
case PDO::FETCH_OBJ:
break;
default:
$resulttype = PDO::FETCH_BOTH;
break;

		}

if($this->seek_array[$query->guid])
{

		}

if($this->seek_array[$query->guid])
{

			$array = $query->fetch(PDO::FETCH_BOTH, $this->seek[$query->guid]['offset'], $this->seek[$query->guid]['row']);
}
else
{
$array = $query->fetch(PDO::FETCH_BOTH);

			$array = $query->fetch($resulttype, $this->seek_array[$query->guid]['offset'], $this->seek_array[$query->guid]['row']);
}
else
{
$array = $query->fetch($resulttype);

		}

return $array;
}

		}

return $array;
}





	/**
* Moves internal row pointer to the next row
*

	/**
* Moves internal row pointer to the next row
*

	 * @param resource The query resource.
* @param int The pointer to move the row to.

	 * @param PDOStatement $query The query resource.
* @param int $row The pointer to move the row to.

	 */
function seek($query, $row)
{

	 */
function seek($query, $row)
{

		if(!is_object($query))
{
return;
}

		$this->seek_array[$query->guid] = array('offset' => PDO::FETCH_ORI_ABS, 'row' => $row);
}







		$this->seek_array[$query->guid] = array('offset' => PDO::FETCH_ORI_ABS, 'row' => $row);
}

/**

	/**




	 * Return the number of rows resulting from a query.
*

	 * Return the number of rows resulting from a query.
*

	 * @param resource The query resource.

	 * @param PDOStatement $query The query resource.

	 * @return int The number of rows in the result.
*/
function num_rows($query)
{

	 * @return int The number of rows in the result.
*/
function num_rows($query)
{

		if(!is_object($query))
{
return;
}

if(is_numeric(stripos($query->queryString, 'SELECT')))

		if(stripos($query->queryString, 'SELECT') !== false)






		{
$query = $this->db->query($query->queryString);
$result = $query->fetchAll();

		{
$query = $this->db->query($query->queryString);
$result = $query->fetchAll();

Zeile 134Zeile 133
		else
{
return $query->rowCount();

		else
{
return $query->rowCount();

		}

		}

	}

/**
* Return the last id number of inserted data.
*

	}

/**
* Return the last id number of inserted data.
*

	 * @param string The name of the insert id to check. (Optional)

	 * @param string $name The name of the insert id to check. (Optional)

	 * @return int The id number.
*/
function insert_id($name="")

	 * @return int The id number.
*/
function insert_id($name="")

Zeile 151Zeile 150
	/**
* Return an error number.
*

	/**
* Return an error number.
*

	 * @param resource The query resource.

	 * @param PDOStatement $query The query resource.

	 * @return int The error number of the current error.
*/
function error_number($query)
{

	 * @return int The error number of the current error.
*/
function error_number($query)
{

		if(!is_object($query) || !method_exists($query, "errorCode"))

		if(!method_exists($query, "errorCode"))

		{

		{

			return;

			return 0;

		}

$errorcode = $query->errorCode();

		}

$errorcode = $query->errorCode();

Zeile 168Zeile 167

/**
* Return an error string.


/**
* Return an error string.

	 *
* @param resource The query resource.
* @return int The error string of the current error.
*/

	 *
* @param PDOStatement $query The query resource.
* @return array The error string of the current error.
*/

	function error_string($query)

	function error_string($query)

	{
if(!is_object($query) || !method_exists($query, "errorInfo"))

	{
if(!method_exists($query, "errorInfo"))

		{
return $this->db->errorInfo();
}
return $query->errorInfo();

		{
return $this->db->errorInfo();
}
return $query->errorInfo();

	}

/**
* Roll back the last query.
*
* @return boolean true on success, false otherwise.
*/
function roll_back()
{
//return $this->db->rollBack();

 
	}

/**
* Returns the number of affected rows in a query.
*

	}

/**
* Returns the number of affected rows in a query.
*

 
	 * @param PDOStatement $query

	 * @return int The number of affected rows.
*/
function affected_rows($query)

	 * @return int The number of affected rows.
*/
function affected_rows($query)

Zeile 204Zeile 194
	/**
* Return the number of fields.
*

	/**
* Return the number of fields.
*

	 * @param resource The query resource.

	 * @param PDOStatement $query The query resource.

	 * @return int The number of fields.
*/
function num_fields($query)

	 * @return int The number of fields.
*/
function num_fields($query)

Zeile 212Zeile 202
		return $query->columnCount();
}


		return $query->columnCount();
}


 
	/**
* Escape a string according to the pdo escape format.
*
* @param string $string The string to be escaped.
* @return string The escaped string.
*/

	function escape_string($string)
{
$string = $this->db->quote($string);

	function escape_string($string)
{
$string = $this->db->quote($string);

Zeile 226Zeile 222
	/**
* Return a selected attribute
*

	/**
* Return a selected attribute
*

	 * @param constant The attribute to check.

	 * @param string $attribute The attribute to check.

	 * @return string The value of the attribute.
*/
function get_attribute($attribute)

	 * @return string The value of the attribute.
*/
function get_attribute($attribute)