StatementCommon Class Reference

Inherits Statement.

Inherited by MSSQLStatement, MySQLStatement, OCI8Statement, PgSQLStatement, and SQLiteStatement.

List of all members.

Public Member Functions

Public Attributes


Constructor & Destructor Documentation

StatementCommon::StatementCommon ( &$  conn)

 

Create new statement instance.

Parameters:
Connection $conn Connection object


Member Function Documentation

StatementCommon::setLimit ( $  v)

 

Sets the maximum number of rows to return from db. This will affect the SQL if the RDBMS supports native LIMIT; if not, it will be emulated. Limit only applies to queries (not update sql).

Parameters:
int $v Maximum number of rows or 0 for all rows.

Returns void

Reimplemented from Statement.

StatementCommon::getLimit ()

 

Returns the maximum number of rows to return or 0 for all.

Returns int

Reimplemented from Statement.

StatementCommon::setOffset ( $  v)

 

Sets the start row. This will affect the SQL if the RDBMS supports native OFFSET; if not, it will be emulated. Offset only applies to queries (not update) and only is evaluated when LIMIT is set!

Parameters:
int $v

Returns void

Reimplemented from Statement.

StatementCommon::getOffset ()

 

Returns the start row. Offset only applies when Limit is set!

Returns int

Reimplemented from Statement.

StatementCommon::close ()

 

Free resources associated with this statement. Some drivers will need to implement this method to free database result resources.

Returns void

Reimplemented from Statement.

& StatementCommon::execute ( $  sql,  $  fetchmode = null )

 

Generic execute() function has to check to see whether SQL is an update or select query.

If you already know whether it's a SELECT or an update (manipulating) SQL, then use the appropriate method, as this one will incurr overhead to check the SQL.

NOTICE: This function's return values are slightly different compared to the PHP5 version.

Parameters:
int $fetchmode Fetchmode (only applies to queries).

Returns mixed Number of affected rows on an update, a result set on a query or a SQLException on error.

Reimplemented from Statement.

& StatementCommon::getResultSet ()

 

Get result set. This assumes that the last thing done was an executeQuery() or an execute() with SELECT-type query.

Returns RestultSet (or null if none)

Reimplemented from Statement.

StatementCommon::getUpdateCount ()

 

Get update count.

Returns int Number of records affected, or null if not applicable.

Reimplemented from Statement.

StatementCommon::isSelect ( $  sql)

 

Returns whether the passed SQL is a SELECT statement.

Returns true if SQL starts with 'SELECT' but not 'SELECT INTO'. This exists to support the execute() function -- which could either execute an update or a query.

Currently this function does not take into consideration comments, primarily because there are a number of different comment options for different drivers:

   -- SQL-defined comment, but not truly comment in Oracle
  # comment in mysql
  /* comment in mssql, others * /
  // comment sometimes?
  REM also comment ...
 

If you're wondering why we can't just execute the query and look at the return results to see whether it was an update or a select, the reason is that for update queries we need to do stuff before we execute them -- like start transactions if auto-commit is off.

Parameters:
string $sql

Returns boolean Whether statement is a SELECT SQL statement.

See also execute()

& StatementCommon::executeQuery ( $  sql,  $  fetchmode = null )

 

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

Parameters:
string $sql This method may optionally be called with the SQL statement.
int $fetchmode The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC).

Returns object Creole::ResultSet

Exceptions:
SQLException If there is an error executing the specified query.

Reimplemented from Statement.

Reimplemented in MSSQLStatement.

StatementCommon::executeUpdate ( $  sql)

 

Executes the SQL INSERT, UPDATE, or DELETE statement in this PreparedStatement object.

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

object SQLException if a database access error occurs.

Reimplemented from Statement.

StatementCommon::getMoreResults ()

 

Gets next result set (if this behavior is supported by driver). Some drivers (e.g. MSSQL) support returning multiple result sets -- e.g. from stored procedures.

This function also closes any current restult set.

Default behavior is for this function to return false. Driver-specific implementations of this class can override this method if they actually support multiple result sets.

Returns boolean True if there is another result set, otherwise false.

Reimplemented from Statement.

Reimplemented in MSSQLStatement.

& StatementCommon::getConnection ()

 

Gets the db Connection that created this statement.

Returns Connection

Reimplemented from Statement.


Member Data Documentation

StatementCommon::$conn

 

StatementCommon::$resultSet

 

StatementCommon::$updateCount

 

StatementCommon::$warnings = array()

 

StatementCommon::$resultClass

 

StatementCommon::$stmt

 

StatementCommon::$limit = 0

 

StatementCommon::$offset = 0

 


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


Copyright © 2004 Hans Lellelid  
Creole[php4] CVS