[ Index ]
 

Code source de WebCalendar 1.0.5

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables | Statistiques

title

Body

[fermer]

/includes/ -> php-dbi.php (sommaire)

Generic database access. The functions defined in this file are meant to provide a single API to the different PHP database APIs.  Unfortunately, this is necessary since PHP does not yet have a common db API.  The value of <var>$GLOBALS["db_type"]</var> should be defined somewhere to one of the following: - mysql - mssql - oracle  (This uses the Oracle8 OCI API, so Oracle 8 libs are required) - postgresl - odbc - ibase (Interbase)

Author: Craig Knudsen <cknudsen@cknudsen.com>
Copyright: Craig Knudsen, <cknudsen@cknudsen.com>, http://www.k5n.us/cknudsen
License: http://www.gnu.org/licenses/gpl.html GNU GPL
Poids: 509 lignes (19 kb)
Inclus ou requis: 6 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 8 fonctions

  dbi_connect()
  dbi_close()
  dbi_query()
  dbi_fetch_row()
  dbi_affected_rows()
  dbi_free_result()
  dbi_error()
  dbi_fatal_error()

Fonctions
Fonctions qui ne font pas partie d'une Classe:

dbi_connect( $host, $login, $password, $database )   X-Ref
Opens up a database connection.

Use a pooled connection if the db supports it and
the <var>db_persistent</var> setting is enabled.

<b>Notes:</b>
- The database type is determined by the global variable
<var>db_type</var>
- For ODBC, <var>$host</var> is ignored, <var>$database</var> = DSN
- For Oracle, <var>$database</var> = tnsnames name
- Use the {@link dbi_error()} function to get error information if the connection
fails

param: string $host     Hostname of database server
param: string $login    Database login
param: string $password Database login password
param: string $database Name of database
return: resource The connection

dbi_close( $conn )   X-Ref
Closes a database connection.

This is not necessary for any database that uses pooled connections such as
MySQL, but a good programming practice.

param: resource $conn The database connection
return: bool True on success, false on error

dbi_query( $sql, $fatalOnError=true, $showError=true )   X-Ref
Executes a SQL query.

<b>Note:</b> Use the {@link dbi_error()} function to get error information
if the connection fails.

param: string $sql          SQL of query to execute
param: bool   $fatalOnError Abort execution if there is a database error?
param: bool   $showError    Display error to user (including possibly the
return: mixed The query result resource on queries (which can then be

dbi_fetch_row( $res )   X-Ref
Retrieves a single row from the database and returns it as an array.

<b>Note:</b> We don't use the more useful xxx_fetch_array because not all
databases support this function.

<b>Note:</b> Use the {@link dbi_error()} function to get error information
if the connection fails.

param: resource $res The database query resource returned from
return: mixed An array of database columns representing a single row in

dbi_affected_rows( $conn, $res )   X-Ref
Returns the number of rows affected by the last INSERT, UPDATE or DELETE.

<b>Note:</b> Use the {@link dbi_error()} function to get error information
if the connection fails.

param: resource $conn The database connection
param: resource $res  The database query resource returned from
return: int The number or database rows affected.

dbi_free_result( $res )   X-Ref
Frees a result set.

param: resource $res The database query resource returned from
return: bool True on success

dbi_error()   X-Ref
Gets the latest database error message.

return: string The text of the last database error.  (The type of

dbi_fatal_error( $msg, $doExit=true, $showError=true )   X-Ref
Displays a fatal database error and aborts execution.

param: string $msg       The database error message
param: bool   $doExit    Abort execution?
param: bool   $showError Show the details of the error (possibly including



Généré le : Fri Nov 30 19:09:19 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics