creole
[ class tree: creole ] [ index: creole ] [ all elements ]

Class: Connection

Source Location: /creole/Connection.php

Interface Overview


Connection is an abstract base class for DB dialect implementations, and must be inherited by all such.


Author(s):

Version:

  • $Revision: 1.27 $

Methods



Class Details

[line 35]
Connection is an abstract base class for DB dialect implementations, and must be inherited by all such.

Developer notes: (1) Make sure that your Connection class can be serialized. See the ConnectionCommon __sleep() and __wakeup() implimentation.




Tags:

version:  $Revision: 1.27 $
author:  Hans Lellelid <hans@xmpl.org>


[ Top ]


Class Methods


method applyLimit [line 133]

void applyLimit( string &$sql, int $offset, int $limit)

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



Tags:

access:  public
throws:  SQLException - if unable to modify query for any reason.


Parameters:

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

[ Top ]

method close [line 166]

void close( )

Free the db resources.



Tags:

access:  public


[ Top ]

method commit [line 192]

void commit( )

Commits statements in a transaction.



Tags:

access:  public


[ Top ]

method connect [line 53]

void connect( array $dsn, [int $flags = false])

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



Tags:

access:  public


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.

[ Top ]

method createStatement [line 121]

Statement createStatement( )

Creates a new empty Statement.



Tags:

access:  public


[ Top ]

method executeQuery [line 143]

object ResultSet executeQuery( string $sql, [int $fetchmode = null])

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



Tags:

access:  public
throws:  SQLException if a database access error occurs.


Parameters:

string   $sql   The SQL statement.
int   $fetchmode  

[ Top ]

method executeUpdate [line 152]

int executeUpdate( string $sql)

Executes the SQL INSERT, UPDATE, or DELETE statement.



Tags:

return:  Number of affected rows (or 0 for drivers that return nothing).
access:  public
throws:  SQLException if a database access error occurs.


Parameters:

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

[ Top ]

method getAutoCommit [line 173]

boolean getAutoCommit( )

Get auto-commit status.



Tags:

access:  public


[ Top ]

method getDatabaseInfo [line 83]

DatabaseInfo 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.




Tags:

access:  public


[ Top ]

method getDSN [line 72]

array getDSN( )

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



Tags:

access:  public
see:  Connection::connect()


[ Top ]

method getFlags [line 65]

int getFlags( )

Get any flags that were passed to connection.



Tags:

access:  public


[ Top ]

method getIdGenerator [line 89]

IdGenerator getIdGenerator( )

Loads and returns an IdGenerator object for current RDBMS.



Tags:

access:  public


[ Top ]

method getResource [line 59]

resource getResource( )

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



Tags:

access:  public


[ Top ]

method getUpdateCount [line 206]

int getUpdateCount( )

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



Tags:

return:  Number of rows affected by the last query.
access:  public


[ Top ]

method prepareCall [line 160]

CallableStatement prepareCall( string $sql)

Creates a CallableStatement object for calling database stored procedures.



Tags:

access:  public


Parameters:

string   $sql  

[ Top ]

method prepareStatement [line 115]

PreparedStatement prepareStatement( string $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 ?




Tags:

access:  public
see:  PreparedStatement::execute()
throws:  SQLException


Parameters:

string   $sql   The query to prepare.

[ Top ]

method rollback [line 198]

void rollback( )

Rollback changes in a transaction.



Tags:

access:  public


[ Top ]

method setAutoCommit [line 186]

void setAutoCommit( boolean $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.




Tags:

access:  public


Parameters:

boolean   $bit   New value for auto commit.

[ Top ]


Documentation generated on Mon, 23 Aug 2004 21:51:17 -0400 by phpDocumentor 1.3.0RC3