Connection Interface Reference

Inherited by MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

List of all members.

Public Member Functions


Member Function Documentation

Connection::connect ( $ dsn, $ flags = false )

 

Connect to a database and log in as the specified user.

Parameters
array $dsn The PEAR-style data source hash.
int $flags (optional) Flags for connection (e.g. Creole::PERSISTENT). These flags may apply to any of the driver classes.

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

resource Connection::getResource ( )

 

Get the PHP native resource for the database connection/link.
Returns resource

int Connection::getFlags ( )

 

Get any flags that were passed to connection.
Returns int

array Connection::getDSN ( )

 

Get the DSN array used by connect() method to connect to database.
See also connect()
Returns array

DatabaseInfo Connection::getDatabaseInfo ( )

 

Gets a DatabaseInfo class for the current database.

This is not modeled on the JDBC MetaData class, but provides a possibly more useful metadata system. All the same, there may eventually be a getMetaData() which returns a class that behaves like JDBC's DatabaseMetaData.

Returns DatabaseInfo

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

IdGenerator Connection::getIdGenerator ( )

 

Loads and returns an IdGenerator object for current RDBMS.
Returns IdGenerator

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

PreparedStatement Connection::prepareStatement ( $ sql )

 

Prepares a query for multiple execution with execute().

With some database backends, this is emulated. prepare() requires a generic query as string like "INSERT INTO numbers VALUES(?,?,?)". The ? are placeholders.

IMPORTANT: All occurrences of the placeholder (?) will be assumed to be a parameter. Therefore be sure not to have ? anywhere else in the query.

So, ... DO NOT MIX WILDCARDS WITH ALREADY-PREPARED QUERIES

INCORRECT: SELECT * FROM mytable WHERE id = ? AND title = 'Where are you?' and body LIKE ?

CORRECT: SELECT * FROM mytable WHERE id = ? AND title = ? and body LIKE ?

Parameters
string $sql The query to prepare.

Returns PreparedStatement
Exceptions
SQLException 

See also PreparedStatement::execute()

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

Statement Connection::createStatement ( )

 

Creates a new empty Statement.
Returns Statement

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

void Connection::applyLimit ( &$ sql, $ offset, $ limit )

 

If RDBMS supports native LIMIT/OFFSET then query SQL is modified so that no emulation is performed in ResultSet.

Parameters
string &$sql The query that will be modified.
int $offset
int $limit

Returns void
Exceptions
SQLException - if unable to modify query for any reason.

Implemented in MSSQLConnection, and OCI8Connection.

object Connection::executeQuery ( $ sql, $ fetchmode = null )

 

Executes the SQL query in this PreparedStatement object and returns the resultset.

Parameters
string $sql The SQL statement.
int $fetchmode

Returns object ResultSet
Exceptions
SQLException if a database access error occurs.

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

int Connection::executeUpdate ( $ sql )

 

Executes the SQL INSERT, UPDATE, or DELETE statement.

Parameters
string $sql This method may optionally be called with the SQL statement.

Returns int Number of affected rows (or 0 for drivers that return nothing).
Exceptions
SQLException if a database access error occurs.

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

CallableStatement Connection::prepareCall ( $ sql )

 

Creates a CallableStatement object for calling database stored procedures.

Parameters
string $sql

Returns CallableStatement

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

void Connection::close ( )

 

Free the db resources.
Returns void

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

boolean Connection::getAutoCommit ( )

 

Get auto-commit status.

Returns boolean

void Connection::setAutoCommit ( $ bit )

 

Enable/disable automatic commits.

Pushes SQLWarning onto $warnings stack if the autocommit value is being changed mid-transaction. This function is overridden by driver classes so that they can perform the necessary begin/end transaction SQL.

If auto-commit is being set to TRUE, then the current transaction will be committed immediately.

Parameters
boolean $bit New value for auto commit.

Returns void

Connection::commit ( )

 

Commits statements in a transaction.

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

Connection::rollback ( )

 

Rollback changes in a transaction.

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.

int Connection::getUpdateCount ( )

 

Gets the number of rows affected by the data manipulation query.

Returns int Number of rows affected by the last query.

Implemented in MSSQLConnection, MySQLConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.


This file is part of the Creole[php5] library.


Copyright © 2004 Hans Lellelid  
Creole[php5] CVS