Public Member Functions | |
connect ($dsn, $flags=false) | |
Connect to a database and log in as the specified user. | |
getResource () | |
Get the PHP native resource for the database connection/link. | |
getFlags () | |
Get any flags that were passed to connection. | |
getDSN () | |
Get the DSN array used by connect() method to connect to database. | |
getDatabaseInfo () | |
Gets a DatabaseInfo class for the current database. | |
getIdGenerator () | |
Loads and returns an IdGenerator object for current RDBMS. | |
prepareStatement ($sql) | |
Prepares a query for multiple execution with execute(). | |
createStatement () | |
Creates a new empty Statement. | |
applyLimit (&$sql, $offset, $limit) | |
If RDBMS supports native LIMIT/OFFSET then query SQL is modified so that no emulation is performed in ResultSet. | |
executeQuery ($sql, $fetchmode=null) | |
Executes the SQL query in this PreparedStatement object and returns the resultset. | |
executeUpdate ($sql) | |
Executes the SQL INSERT, UPDATE, or DELETE statement. | |
prepareCall ($sql) | |
Creates a CallableStatement object for calling database stored procedures. | |
close () | |
Free the db resources. | |
isConnected () | |
Returns false if connection is closed. | |
getAutoCommit () | |
Get auto-commit status. | |
setAutoCommit ($bit) | |
Enable/disable automatic commits. | |
begin () | |
Begins a transaction (if supported). | |
commit () | |
Commits statements in a transaction. | |
rollback () | |
Rollback changes in a transaction. | |
getUpdateCount () | |
Gets the number of rows affected by the data manipulation query. |
Definition at line 35 of file Connection.php.
Connection::applyLimit | ( | &$ | sql, | |
$ | offset, | |||
$ | limit | |||
) |
If RDBMS supports native LIMIT/OFFSET then query SQL is modified so that no emulation is performed in ResultSet.
string | &$sql The query that will be modified. | |
int | $offset | |
int | $limit |
SQLException | - if unable to modify query for any reason. |
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::begin | ( | ) |
Connection::close | ( | ) |
Free the db resources.
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::commit | ( | ) |
Connection::connect | ( | $ | dsn, | |
$ | flags = false | |||
) |
Connect to a database and log in as the specified user.
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 DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::createStatement | ( | ) |
Creates a new empty Statement.
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::executeQuery | ( | $ | sql, | |
$ | fetchmode = null | |||
) |
Executes the SQL query in this PreparedStatement object and returns the resultset.
string | $sql The SQL statement. | |
int | $fetchmode |
SQLException | if a database access error occurs. |
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::executeUpdate | ( | $ | sql | ) |
Executes the SQL INSERT, UPDATE, or DELETE statement.
string | $sql This method may optionally be called with the SQL statement. |
SQLException | if a database access error occurs. |
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::getAutoCommit | ( | ) |
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.
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::getDSN | ( | ) |
Get the DSN array used by connect() method to connect to database.
Implemented in DebugConnection.
Referenced by DatabaseInfo::__construct(), and OCI8DatabaseInfo::__construct().
Connection::getFlags | ( | ) |
Get any flags that were passed to connection.
Implemented in DebugConnection.
Referenced by ResultSetCommon::__construct().
Connection::getIdGenerator | ( | ) |
Loads and returns an IdGenerator object for current RDBMS.
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::getResource | ( | ) |
Get the PHP native resource for the database connection/link.
Implemented in DebugConnection.
Referenced by DatabaseInfo::__construct().
Connection::getUpdateCount | ( | ) |
Gets the number of rows affected by the data manipulation query.
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::isConnected | ( | ) |
Connection::prepareCall | ( | $ | sql | ) |
Creates a CallableStatement object for calling database stored procedures.
string | $sql |
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
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 ?
string | $sql The query to prepare. |
SQLException |
Implemented in DebugConnection, MSSQLConnection, MySQLConnection, MySQLiConnection, ODBCConnection, OCI8Connection, PgSQLConnection, and SQLiteConnection.
Connection::rollback | ( | ) |
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.
boolean | $bit New value for auto commit. |
Implemented in DebugConnection.