/inc/formslib/sql.php

Description

SQL interface functions, return statuscodes as appropriate

The SQL functions are encapsulated here to make it easier to keep track of them, particularly for porting to other databases. Encapsulation is done here with a functional interface not an object interface.

  • version: $Id$
  • filesource: Source Code for this file
  • license: GNU Public License
  • copyright: Copyright Stuart Prescott
  • author: Stuart Prescott
  • todo: //TODO: work out why we didn't just use PEAR::DB and be done with it right from the beginning
Includes
require_once ('inc/statuscodes.php') (line 24)

status codes for success/failure of database actions

require_once ('inc/typeinfo.php') (line 20)

Load ancillary functions

Functions
db_fetch_array (line 91)

return the next row from a query

  • return: next row from query
array db_fetch_array (resource $sql)
  • resource $sql: db query handle
db_get (line 52)

run an sql query and return the sql handle for further requests

  • return: mysql query handle
resource db_get (string $q, [boolean $fatal_sql = 0])
  • string $q: the sql query, properly constructed and quoted
  • boolean $fatal_sql: db errors are fatal
db_get_name (line 203)

returns the name of the database software that is being talked to

  • return: database server software name
string db_get_name ()
db_get_single (line 71)

run an sql query and return the single (or first) row returned

  • return: array if successful, false if error
mixed db_get_single (string $q, [boolean $fatal_sql = 0])
  • string $q: the sql query, properly constructed and quoted
  • boolean $fatal_sql: db errors are fatal
db_get_version (line 193)

returns the current version of the database that is being talked to

  • return: database version
string db_get_version ()
db_new_id (line 81)

return the last insert ID from the database

  • return: id (row number) of previous insert operation
integer db_new_id ()
db_num_rows (line 103)

get the number of rows returned by a query

  • return: number of rows
integer db_num_rows (resource $sql)
  • resource $sql: db query handle
db_quiet (line 33)

run an sql query without returning data

  • return: status from statuscodes
integer db_quiet (string $q, [boolean $fatal_sql = 0])
  • string $q: the sql query, properly constructed and quoted
  • boolean $fatal_sql: db errors are fatal
echoSQL (line 113)

echo the SQL query to the browser

void echoSQL (string $echo, [boolean $success = 0])
  • string $echo: the sql query
  • boolean $success: query was successful
echoSQLerror (line 129)

echo the SQL query to the browser

void echoSQLerror (string $echo, [boolean $fatal = 0])
  • string $echo: the sql query
  • boolean $fatal: die on error
quickSQLSelect (line 162)

construct and perform a simple SQL select

  • return: array if successful, false if error
  • global: string $TABLEPREFIX: prefix for tabl nname
mixed quickSQLSelect (string $table, mixed $key, mixed $value, [boolean $fatal = 1], [boolean $countonly = 0])
  • string $table: name of the table (will have TABLEPREFIX added to it
  • mixed $key: single column name or list of columns for the WHERE clause
  • mixed $value: single value or list of values for WHERE $key=$value
  • boolean $fatal: die on error
  • boolean $countonly: run a COUNT(*) query not a SELECT query

Documentation generated on Tue, 06 Mar 2007 10:01:59 +0000 by phpDocumentor 1.3.0