Adodb Dokumentation  V5.14 8 Sept 2011
DB Klassenreferenz

Öffentliche Methoden

 factory ($type)
 connect ($dsn, $options=false)
 apiVersion ()
 isError ($value)
 isWarning ($value)
 parseDSN ($dsn)
 assertExtension ($name)

Ausführliche Beschreibung

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.


Dokumentation der Elementfunktionen

Return the DB API version

Rückgabe:
int the DB API version number

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

Parameter:
$namethe base name of the extension (without the .so or .dll suffix)
Rückgabe:
bool true if the extension was already or successfully loaded, false if it could not be loaded

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

Parameter:
$dsnmixed "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.
$optionsmixed 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.
Rückgabe:
object a newly created DB connection object, or a DB error object on error
Siehe auch:
DB::parseDSN
DB::isError

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

Parameter:
$typestring database type, for example "mysql"
Rückgabe:
object a newly created DB object, or a DB error code on error

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

Parameter:
$valueint result code
Rückgabe:
bool whether $value is an error

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');
        }

Hier ist ein Graph der zeigt, wo diese Funktion aufgerufen wird:

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.

Parameter:
$valuemixed result value
Rückgabe:
bool whether $value is a warning

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"));*/
        }

Die Dokumentation für diese Klasse wurde erzeugt aufgrund der Datei: