Reference Manuals

phppdo

phppdo — This class implements an generic PDO-based DBAPI

phppdo is part of the DBAPI package.

Synopsis

class phppdo extends DBAPI {
        private        int                 $affected_rows
        private        resource            $link
        private        string              $query

        public         phppdo              __construct               ( string $dsn,
                                                                       string $username,
                                                                       string $password,
                                                                       string $options );
        public         int                 affectedrows              ( void );
        public         void                close                     ( void );
        public         string              errno                     ( void );
        public         string              error                     ( void );
        public         mixed               escape                    ( mixed $var );
        protected      resource            execute_query             ( string $query );
        public         array               fetchrow                  ( resource $result );
        public         array               fetchrowset               ( resource $result );
        public         void                freeresult                ( resource $result );
        public         int                 lastid                    ( void );
        protected      string              limit_query               ( string $query,
                                                                       int $length,
                                                                       int $start );
}

Object Hierarchy

DBAPI
 +----phppdo

Description

This class implements an generic PDO-based DBAPI

Attribute Details

$affected_rows

private        int            $affected_rows

The number of rows affected by the last query

Default value: empty string


private        resource       $link

The database connection resource

Default value: empty string


$query

private        string         $query

A copy of the query. Used for reporting errors

Default value: empty string

Method Details

__construct()

public         phppdo         __construct               ( string $dsn,
                                                          string $username,
                                                          string $password,
                                                          string $options );

Create a database connection

This function is identical to PHP's PDO() constructor.

$dsn
The DSN to open the SQLite file
$username
Unused for SQLite
$password
Unused for SQLite
$options
Unused for SQLite

affectedrows()

public         int            affectedrows              ( void );

Get the number of rows affected by the last query


close()

public         void           close                     ( void );

Close the connection


errno()

public         string         errno                     ( void );

Return the last SQL error number


error()

public         string         error                     ( void );

Return the last SQL error message


escape()

public         mixed          escape                    ( mixed $var );

Escape a variable to safely use in in SQL

$var
The varibale to escape

execute_query()

protected      resource       execute_query             ( string $query );

Execute a single SQL query

$query
The SQL query to execute

fetchrow()

public         array          fetchrow                  ( resource $result );

Fetch a single row from the SQL result set. If no result is specified, it uses the last returned result

$result
The SQL result resource. Default is NULL

fetchrowset()

public         array          fetchrowset               ( resource $result );

Fetch an array of rows from the SQL result set. If no result is specified, it uses the last returned result

$result
The SQL result resource. Default is NULL

freeresult()

public         void           freeresult                ( resource $result );

Free an SQL result resource. If no result is specified, it uses the last returned result

There is no function to free a PDO result resource

$result
The result resource to free. Default is NULL

lastid()

public         int            lastid                    ( void );

Get the unique ID of the last row that was insterted in the database


limit_query()

protected      string         limit_query               ( string $query,
                                                          int $length,
                                                          int $start );

Modify a query to limit the size of the returned result set

$query
The query to modify
$length
The maximum size of the result set
$start
The offset into the result set. Default is 0