|
Adodb Dokumentation
V5.14 8 Sept 2011
|
Öffentliche Methoden | |
| factory ($type) | |
| connect ($dsn, $options=false) | |
| apiVersion () | |
| isError ($value) | |
| isWarning ($value) | |
| parseDSN ($dsn) | |
| assertExtension ($name) | |
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.
Definiert in Zeile 101 der Datei adodb-pear.inc.php.
| apiVersion | ( | ) |
Return the DB API version
Definiert in Zeile 199 der Datei adodb-pear.inc.php.
{
return 2;
}
| assertExtension | ( | $ | name | ) |
Load a PHP database extension if it is not loaded already.
public
| $name | the base name of the extension (without the .so or .dll suffix) |
Definiert in Zeile 361 der Datei adodb-pear.inc.php.
{
if (!extension_loaded($name)) {
$dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so';
@dl($name . $dlext);
}
if (!extension_loaded($name)) {
return false;
}
return true;
}
| connect | ( | $ | dsn, |
| $ | options = false |
||
| ) |
Create a new DB object and connect to the specified database
| $dsn | mixed "data source name", see the DB::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by DB::parseDSN. |
| $options | mixed if boolean (or scalar), tells whether this connection should be persistent (for backends that support this). This parameter can also be an array of options, see DB_common::setOption for more information on connection options. |
Definiert in Zeile 139 der Datei adodb-pear.inc.php.
{
if (is_array($dsn)) {
$dsninfo = $dsn;
} else {
$dsninfo = DB::parseDSN($dsn);
}
switch ($dsninfo["phptype"]) {
case 'pgsql': $type = 'postgres7'; break;
case 'ifx': $type = 'informix9'; break;
default: $type = $dsninfo["phptype"]; break;
}
if (is_array($options) && isset($options["debug"]) &&
$options["debug"] >= 2) {
// expose php errors with sufficient debug level
@include_once("adodb-$type.inc.php");
} else {
@include_once("adodb-$type.inc.php");
}
@$obj = NewADOConnection($type);
if (!is_object($obj)) {
$obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
return $obj;
}
if (is_array($options)) {
foreach($options as $k => $v) {
switch(strtolower($k)) {
case 'persist':
case 'persistent': $persist = $v; break;
#ibase
case 'dialect': $obj->dialect = $v; break;
case 'charset': $obj->charset = $v; break;
case 'buffers': $obj->buffers = $v; break;
#ado
case 'charpage': $obj->charPage = $v; break;
#mysql
case 'clientflags': $obj->clientFlags = $v; break;
}
}
} else {
$persist = false;
}
if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket'];
else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port'];
if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']);
if (!$ok) $obj = ADODB_PEAR_Error();
return $obj;
}
| factory | ( | $ | type | ) |
Create a new DB object for the specified database type
| $type | string database type, for example "mysql" |
Definiert in Zeile 112 der Datei adodb-pear.inc.php.
{
include_once(ADODB_DIR."/drivers/adodb-$type.inc.php");
$obj = NewADOConnection($type);
if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1);
return $obj;
}
| isError | ( | $ | value | ) |
Tell whether a result code from a DB method is an error
| $value | int result code |
Definiert in Zeile 211 der Datei adodb-pear.inc.php.
{
if (!is_object($value)) return false;
$class = strtolower(get_class($value));
return $class == 'pear_error' || is_subclass_of($value, 'pear_error') ||
$class == 'db_error' || is_subclass_of($value, 'db_error');
}

| isWarning | ( | $ | value | ) |
Tell whether a result code from a DB method is a warning. Warnings differ from errors in that they are generated by DB, and are not fatal.
| $value | mixed result value |
Definiert in Zeile 229 der Datei adodb-pear.inc.php.
{
return false;
/*
return is_object($value) &&
(get_class( $value ) == "db_warning" ||
is_subclass_of($value, "db_warning"));*/
}