Source for file dpdb_mysql.php
Documentation is available at dpdb_mysql.php
* MySQL database functions
* A very simple layer over MySQL functions, providing the same interface as
* dpdb_mdb2.php (which is a layer over the MDB2 database abstraction layer).
* Either this file or dpdb_mdb2.php is included, based on settings in
* DutchPIPE version 0.4; PHP version 5
* LICENSE: This source file is subject to version 1.0 of the DutchPIPE license.
* If you did not receive a copy of the DutchPIPE license, you can obtain one at
* http://dutchpipe.org/license/1_0.txt or by sending a note to
* license@dutchpipe.org, in which case you will be mailed a copy immediately.
* @author Lennert Stock <ls@dutchpipe.org>
* @copyright 2006, 2007 Lennert Stock
* @license http://dutchpipe.org/license/1_0.txt DutchPIPE License
* @version Subversion: $Id: dpdb_mysql.php 293 2007-08-25 23:11:20Z ls $
* @link http://dutchpipe.org/manual/package/DutchPIPE
* @see dpuniverse-ini.php, dpdb_mdb2.php
$grMySqlConnection = NULL;
* Connects to the database server and sets it the current database
* Prints an error message to the server output in case of an error
* @return boolean MySQL link identifier on success, FALSE on failure
* @see DPUNIVERSE_MYSQL_HOST, PUNIVERSE_MYSQL_USER,
* DPUNIVERSE_MYSQL_PASSWORD, http://www.php.net/mysql_connect,
* http://www.php.net/mysql_select_db, dp_db_query, dp_db_exec,
* dp_db_fetch_one, dp_db_fetch_row, dp_db_quote, dp_db_num_rows,
* dp_db_next_id, dp_db_free
global $grMySqlConnection;
if ($grMySqlConnection) {
return $grMySqlConnection;
$grMySqlConnection = & $connection;
* Sends a MySQL query of type SELECT, SHOW, EXPLAIN, DESCRIBE, ...
* Prints an error message to the server output in case of an error
* @param string $sql SQL statement
* @return mixed a MySQL resource or FALSE on failure
* @see http://www.php.net/mysql_query, dp_db_connect, dp_db_exec,
* dp_db_fetch_one, dp_db_fetch_row, dp_db_quote, dp_db_num_rows,
* Sends a MySQL query of type DELETE, INSERT, REPLACE, UPDATE, ...
* Prints an error message to the server output in case of an error
* @param string $sql SQL statement
* @return mixed number of affected rows or FALSE on failure
* @see http://www.php.net/mysql_query, dp_db_connect, dp_db_query,
* dp_db_quote, dp_db_next_id
* Prints an error message to the server output in case of an error
* @param resource $result result resource from dp_db_query()
* @param int $row row number from result, starts at 0
* @param int $field optional field name or offset, 0 by default
* @return mixed string with contents of one cell, or FALSE on failure
* @see http://www.php.net/mysql_result, dp_db_connect, dp_db_query,
* dp_db_fetch_row, dp_db_quote, dp_db_num_rows, dp_db_free
echo "dp_db_fetch_one: Failed to fetch data\n";
* Gets a result row as an enumerated array
* @param resource $result result resource from dp_db_query()
* @return mixed numerical array of strings with row data, FALSE if
* @see http://www.php.net/mysql_fetch_row, dp_db_connect, dp_db_query,
* dp_db_fetch_one, dp_db_quote, dp_db_num_rows, dp_db_free
* Escapes special characters in a string for use in a SQL statement
* Escapes the value given in the first argument. All other arguments are
* ignored and only used, when given, by the MDB2 equivalent function.
* @param string $val string that is to be escaped
* @return mixed escaped string, or FALSE on error
* @see http://www.php.net/mysql_real_escape_string, dp_db_query,
function dp_db_quote($val, $type = NULL, $quote = TRUE, $escWildcards = FALSE)
* Gets number of rows in result
* Prints an error message to the server output in case of an error
* @param resource $result result resource from dp_db_query()
* @return mixed number of rows in a result set, or FALSE on failure
* @see http://www.php.net/mysql_num_rows, dp_db_query
if (FALSE === $num_rows) {
echo "dp_db_num_rows: Failed to get number of rows\n";
* Gets the next primary ID for an INSERT
* Prints an error message to the server output in case of an error
* @param string $table table name
* @param string $idColumn field name
* @return mixed integer with next id, or FALSE on failure
$result = mysql_query($sql = "SELECT MAX($idColumn) FROM $table", $link);
echo "dp_db_fetch_one: Failed to fetch next id\n";
* @param resource $result result resource from dp_db_query()
* @return boolean TRUE on success or FALSE on failure
* @see http://www.php.net/mysql_free_result, dp_db_query,
* dp_db_fetch_one, dp_db_fetch_row
|