[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Pear/ -> DB.php (sommaire)

This is a special constant that tells DB the user hasn't specified any particular get mode, so the default should be used.

Poids: 1114 lignes (34 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 1 fichier
 Pear/PEAR.php

Définit 4 classes

DB:: (9 méthodes):
  factory()
  connect()
  apiVersion()
  isError()
  isConnection()
  isManip()
  errorMessage()
  parseDSN()
  assertExtension()

DB_Error:: (1 méthode):
  DB_Error()

DB_result:: (10 méthodes):
  DB_result()
  setOption()
  fetchRow()
  fetchInto()
  numCols()
  numRows()
  nextResult()
  free()
  tableInfo()
  getRowCounter()

DB_row:: (1 méthode):
  DB_row()


Classe: DB  - X-Ref

The main "DB" class is simply a container class with some static
methods for creating DB objects as well as some utility functions
common to all parts of DB.

The object model of DB is as follows (indentation means inheritance):

DB           The main DB class.  This is simply a utility class
with some "static" methods for creating DB objects as
well as common utility functions for other DB classes.

DB_common    The base for each DB implementation.  Provides default
|            implementations (in OO lingo virtual methods) for
|            the actual DB implementations as well as a bunch of
|            query utility functions.
|
+-DB_mysql   The DB implementation for MySQL.  Inherits DB_common.
When calling DB::factory or DB::connect for MySQL
connections, the object returned is an instance of this
class.

factory($type, $options = false)   X-Ref
Create a new DB object for the specified database type.

Allows creation of a DB_<driver> object from which the object's
methods can be utilized without actually connecting to a database.

param: string $type    database type, for example "mysql"
param: array  $options associative array of option names and values
return: object  a new DB object.  On error, an error object.

connect($dsn, $options = array()   X-Ref
Create a new DB object and connect to the specified database.

Example 1.
<code> <?php
require_once 'DB.php';

$dsn = 'mysql://user:password@host/database'
$options = array(
'debug'       => 2,
'portability' => DB_PORTABILITY_ALL,
);

$dbh =& DB::connect($dsn, $options);
if (DB::isError($dbh)) {
die($dbh->getMessage());
}
?></code>

param: mixed $dsn      string "data source name" or an array in the
param: array $options  an associative array of option names and
return: object  a newly created DB connection object, or a DB

apiVersion()   X-Ref
Return the DB API version

return: int the DB API version number

isError($value)   X-Ref
Tell whether a result code from a DB method is an error

param: int $value result code
return: bool whether $value is an error

isConnection($value)   X-Ref
Tell whether a value is a DB connection

param: mixed $value value to test
return: bool whether $value is a DB connection

isManip($query)   X-Ref
Tell whether a query is a data manipulation query (insert,
update or delete) or a data definition query (create, drop,
alter, grant, revoke).

param: string $query the query
return: boolean whether $query is a data manipulation query

errorMessage($value)   X-Ref
Return a textual error message for a DB error code

param: integer $value error code
return: string error message, or false if the error code was

parseDSN($dsn)   X-Ref
Parse a data source name.

Additional keys can be added by appending a URI query string to the
end of the DSN.

The format of the supplied DSN is in its fullest form:
<code>
phptype(dbsyntax)://username:password@protocol+hostspec/database?option=8&another=true
</code>

Most variations are allowed:
<code>
phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644
phptype://username:password@hostspec/database_name
phptype://username:password@hostspec
phptype://username@hostspec
phptype://hostspec/database
phptype://hostspec
phptype(dbsyntax)
phptype
</code>

author: Tomas V.V.Cox <cox@idecnet.com>
param: string $dsn Data Source Name to be parsed
return: array an associative array with the following keys:

assertExtension($name)   X-Ref
Load a PHP database extension if it is not loaded already.

param: string $name the base name of the extension (without the .so or
return: boolean true if the extension was already or successfully

Classe: DB_Error  - X-Ref

DB_Error implements a class for reporting portable database error
messages.

DB_Error($code = DB_ERROR, $mode = PEAR_ERROR_RETURN,$level = E_USER_NOTICE, $debuginfo = null)   X-Ref
DB_Error constructor.

param: mixed   $code   DB error code, or string with error message.
param: integer $mode   what "error mode" to operate in
param: integer $level  what error level to use for $mode & PEAR_ERROR_TRIGGER
param: mixed   $debuginfo  additional debug info, such as the last query

Classe: DB_result  - X-Ref

This class implements a wrapper for a DB result set.
A new instance of this class will be returned by the DB implementation
after processing a query that returns data.

DB_result(&$dbh, $result, $options = array()   X-Ref
DB_result constructor.

param: resource &$dbh   DB object reference
param: resource $result  result resource id
param: array    $options assoc array with optional result options

setOption($key, $value = null)   X-Ref
Pas de description

fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)   X-Ref
Fetch a row of data and return it by reference into an array.

The type of array returned can be controlled either by setting this
method's <var>$fetchmode</var> parameter or by changing the default
fetch mode setFetchMode() before calling this method.

There are two options for standardizing the information returned
from databases, ensuring their values are consistent when changing
DBMS's.  These portability options can be turned on when creating a
new DB object or by using setOption().

+ <samp>DB_PORTABILITY_LOWERCASE</samp>
convert names of fields to lower case

+ <samp>DB_PORTABILITY_RTRIM</samp>
right trim the data

param: int $fetchmode  how the resulting array should be indexed
param: int $rownum     the row number to fetch
return: array  a row of data, null on no more rows or PEAR_Error

fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)   X-Ref
Fetch a row of data into an array which is passed by reference.

The type of array returned can be controlled either by setting this
method's <var>$fetchmode</var> parameter or by changing the default
fetch mode setFetchMode() before calling this method.

There are two options for standardizing the information returned
from databases, ensuring their values are consistent when changing
DBMS's.  These portability options can be turned on when creating a
new DB object or by using setOption().

+ <samp>DB_PORTABILITY_LOWERCASE</samp>
convert names of fields to lower case

+ <samp>DB_PORTABILITY_RTRIM</samp>
right trim the data

param: array &$arr       (reference) array where data from the row
param: int   $fetchmode  how the resulting array should be indexed
param: int   $rownum     the row number to fetch
return: mixed  DB_OK on success, null on no more rows or

numCols()   X-Ref
Get the the number of columns in a result set.

return: int the number of columns, or a DB error

numRows()   X-Ref
Get the number of rows in a result set.

return: int the number of rows, or a DB error

nextResult()   X-Ref
Get the next result if a batch of queries was executed.

return: bool true if a new result is available or false if not.

free()   X-Ref
Frees the resources allocated for this result set.

return: int error code

tableInfo($mode = null)   X-Ref


getRowCounter()   X-Ref
returns the actual row number

return: integer

Classe: DB_row  - X-Ref

Pear DB Row Object

DB_row(&$arr)   X-Ref
constructor

param: resource row data as array



Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7