Skip to main content Help Control Panel

Aubagne HipHop

Tout le Hip Hop d'Aubagne et des alentours

Home «   Server software «  

Documentation: shared/sql.php

Class SQL - Virtualize interactions with the database

This script is a reference file of this system.

Licence: GNU Lesser General Public License

Auteurs:

check() - Check presence of SQL back-end

function check()

connect() - Connect to the database server

function &connect($host, $user, $password, $database)

count() - Count selected rows

function count(&$result)

count_tables() - Count tables in database

function count_tables($name, $handle)

debug() - Debug a SQL query

function &debug($query, $silent=FALSE, $connection=NULL)

This function may be invoked explicitly during query optimization. To do that, SQL::query(...) has to be temporarily turned to SQL::debug(...) and resulting data will be put in agents/debug.txt for analysis.

On SELECT this function queries the database two times: a first time to explain the statement, and second time to actually do the job.

errno() - Retrieve last error code, if any

function errno($connection=NULL)

error() - Build standard error message

function error($connection=NULL)

escape() - Escape a string

function &escape($text)

fetch() - Fetch next result as an associative array

function &fetch(&$result)

fetch_row() - Fetch next result as a bare array

function &fetch_row(&$result)

free() - Release a resource

function free(&$result)

get_last_id() - Get the id of the most recent item

function get_last_id()

has_database() - Ensure a database exists

function has_database($name, $handle)

initialize() - Initialize connections to the database

function initialize()

ping() - Ping the database

function ping()

This function has to be activated from time to time to keep a live connection to the SQL server.

query() - Query the database

function &query(&$query, $silent=FALSE, $connection=NULL)

This function also remembers any error in $context['error'].

query_count() - Query the database and count rows

function query_count(&$query, $silent=FALSE, $connection=NULL)

This function also remember any error in $context['error']

query_first() - Query the database and return first item

function &query_first(&$query, $silent=FALSE, $connection=NULL)

This function also remember any error in $context['error']

query_scalar() - Query the database and return result as a scalar

function &query_scalar(&$query, $silent=FALSE, $connection=NULL)

This function also remember any error in $context['error']

setup_table() - Create or alter the structure of one table

function setup_table($table, $fields, $indexes)

table_name() - Create a table name

function table_name($name)

Note: this function handles properly the specific case of the table for user profiles. However, you may also have to use a different database connection for queries to this table.

table_stat() - Count of rows in a table

function table_stat($table)

table_name()

function table_name($name)

Tools
Browse the source of this script
Server software