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

Class: PreparedStatementCommon

Source Location: /creole/common/PreparedStatementCommon.php

Class Overview


Class that represents a shared code for handling emulated pre-compiled statements.


Author(s):

Version:

  • $Revision: 1.8 $

Variables

Methods


Child classes:

MSSQLPreparedStatement
MSSQL specific PreparedStatement functions.
MySQLPreparedStatement
MySQL subclass for prepared statements.
ODBCPreparedStatement
ODBC specific PreparedStatement functions.
OCI8PreparedStatement
Oracle (OCI8) implementation of PreparedStatement.
PgSQLPreparedStatement
PgSQL subclass for prepared statements.
SQLitePreparedStatement
MySQL subclass for prepared statements.

Class Details

[line 34]
Class that represents a shared code for handling emulated pre-compiled statements.

Many drivers do not take advantage of pre-compiling SQL statements; for these cases the precompilation is emulated. This emulation comes with slight penalty involved in parsing the queries, but provides other benefits such as a cleaner object model and ability to work with BLOB and CLOB values w/o needing special LOB-specific routines.




Tags:

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


[ Top ]


Class Variables

$boundInVars = array()

[line 78]

Map of index => value for bound params.



Tags:

var:  string[]
access:  protected

Type:   array


[ Top ]

$conn =

[line 40]

The database connection.



Tags:

access:  protected

Type:   Connection


[ Top ]

$limit =  0

[line 46]

Max rows to retrieve from DB.



Tags:

access:  protected

Type:   int


[ Top ]

$offset =  0

[line 53]

Offset at which to start processing DB rows.

"Skip X rows"




Tags:

access:  protected

Type:   int


[ Top ]

$positions =

[line 65]

The string positions of the parameters in the SQL.



Tags:

access:  protected

Type:   array


[ Top ]

$positionsCount =

[line 72]

Number of positions (simply to save processing).



Tags:

access:  protected

Type:   int


[ Top ]

$resultSet =

[line 84]

Temporarily hold a ResultSet object after an execute() query.



Tags:

access:  protected

Type:   ResultSet


[ Top ]

$sql =

[line 59]

The SQL this class operates on.



Tags:

access:  protected

Type:   string


[ Top ]

$updateCount =

[line 90]

Temporary hold the affected row cound after an execute() query.



Tags:

access:  protected

Type:   int


[ Top ]



Class Methods


constructor __construct [line 100]

PreparedStatementCommon __construct( Connection $conn, string $sql, array $positions, restult $stmt)

Create new prepared statement instance.



Tags:

access:  public


Overridden in child classes as:

MSSQLCallableStatement::__construct()
Construct new MSSQLCallableStatement.

Parameters:

object   $conn   Connection object
string   $sql   The SQL to work with.
array   $positions   The positions in SQL of ?'s.
restult   $stmt   If the driver supports prepared queries, then $stmt will contain the statement to use.

[ Top ]

method close [line 205]

void close( )

Nothing to close for emulated prepared statements.



Tags:

access:  public


Overridden in child classes as:

MSSQLCallableStatement::close()
OCI8PreparedStatement::close()
Because MySQL doesn't support prepared statements, this does nothing.

[ Top ]

method escape [line 302]

string escape( string $str)

Escapes special characters (usu. quotes) using native driver function.



Tags:

return:  The escaped string.
access:  protected
abstract:  


Overridden in child classes as:

MSSQLPreparedStatement::escape()
Add quotes using str_replace.
MySQLPreparedStatement::escape()
Quotes string using native mysql function.
ODBCPreparedStatement::escape()
OCI8PreparedStatement::escape()
' -> ''
PgSQLPreparedStatement::escape()
Quotes string using native pgsql function (pg_escape_string).
SQLitePreparedStatement::escape()
Quotes string using native sqlite_escape_string() function.

Parameters:

string   $str   The input string.

[ Top ]

method executeQuery [line 248]

ResultSet executeQuery( [mixed $p1 = null], [int $fetchmode = null])

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

We support two signatures for this method:

  • $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
  • $stmt->executeQuery(array($param1, $param2), ResultSet::FETCHMODE_NUM);




Tags:

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


Overridden in child classes as:

MSSQLPreparedStatement::executeQuery()
MSSQL must emulate OFFSET/LIMIT support.
MSSQLCallableStatement::executeQuery()
ODBCPreparedStatement::executeQuery()
OCI8PreparedStatement::executeQuery()
Executes the SQL query in this PreparedStatement object and returns the resultset generated by the query.

Parameters:

mixed   $p1   Either (array) Parameters that will be set using PreparedStatement::set() before query is executed or (int) fetchmode.
int   $fetchmode   The mode to use when fetching the results (e.g. ResultSet::FETCHMODE_NUM, ResultSet::FETCHMODE_ASSOC).

[ Top ]

method executeUpdate [line 282]

int executeUpdate( [array $params = null])

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



Tags:

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


Overridden in child classes as:

ODBCPreparedStatement::executeUpdate()
OCI8PreparedStatement::executeUpdate()
Executes the SQL INSERT, UPDATE, or DELETE statement in this PreparedStatement object.

Parameters:

array   $params   Parameters that will be set using PreparedStatement::set() before query is executed.

[ Top ]

method getConnection [line 187]

void getConnection( )



Tags:

access:  public
see:  PreparedStatement::getConnection()


[ Top ]

method getLimit [line 137]

void getLimit( )



Tags:

access:  public
see:  PreparedStatement::getLimit()


[ Top ]

method getMoreResults [line 177]

void getMoreResults( )



Tags:

access:  public
see:  PreparedStatement::getMoreResults()


Overridden in child classes as:

MSSQLCallableStatement::getMoreResults()

[ Top ]

method getOffset [line 153]

void getOffset( )



Tags:

access:  public
see:  PreparedStatement::getOffset()


[ Top ]

method getResource [line 197]

null getResource( )

Statement resources do not exist for emulated prepared statements, so this just returns
  1. null
.



Tags:

access:  public


Overridden in child classes as:

MSSQLCallableStatement::getResource()

[ Top ]

method getResultSet [line 161]

void getResultSet( )



Tags:

access:  public
see:  PreparedStatement::getResultSet()


[ Top ]

method getUpdateCount [line 169]

void getUpdateCount( )



Tags:

access:  public
see:  PreparedStatement::getUpdateCount()


[ Top ]

method replaceParams [line 217]

string replaceParams( )

Replaces placeholders with the specified parameter values in the SQL.

This is for emulated prepared statements.




Tags:

return:  New SQL statement with parameters replaced.
access:  protected
throws:  SQLException - if param not bound.


Overridden in child classes as:

ODBCPreparedStatement::replaceParams()
This does nothing since ODBC natively supports prepared statements.

[ Top ]

method set [line 316]

void set( int $paramIndex, mixed $value)

A generic set method.

You can use this if you don't want to concern yourself with the details. It involves slightly more overhead than the specific settesr, since it grabs the PHP type to determine which method makes most sense.




Tags:

throws:  SQLException


Parameters:

int   $paramIndex  
mixed   $value  

[ Top ]

method setArray [line 351]

void setArray( int $paramIndex, array $value)

Sets an array.

Unless a driver-specific method is used, this means simply serializing the passed parameter and storing it as a string.




Overridden in child classes as:

MSSQLCallableStatement::setArray()
PgSQLPreparedStatement::setArray()
Sets an array.

Parameters:

int   $paramIndex  
array   $value  

[ Top ]

method setBlob [line 380]

void setBlob( mixed $paramIndex, mixed $blob)



Tags:



Overridden in child classes as:

MSSQLPreparedStatement::setBlob()
MSSQL-specific implementation of setBlob().
MSSQLCallableStatement::setBlob()
ODBCPreparedStatement::setBlob()
OCI8PreparedStatement::setBlob()
PgSQLPreparedStatement::setBlob()
Applies sqlite_udf_encode_binary() to ensure that binary contents will be handled correctly by sqlite.
SQLitePreparedStatement::setBlob()
Applies sqlite_udf_encode_binary() to ensure that binary contents will be handled correctly by sqlite.

[ Top ]

method setBoolean [line 367]

void setBoolean( int $paramIndex, boolean $value)

Sets a boolean value.

Default behavior is true = 1, false = 0.




Overridden in child classes as:

MSSQLCallableStatement::setBoolean()
PgSQLPreparedStatement::setBoolean()
For setting value of Postgres BOOLEAN column.

Parameters:

int   $paramIndex  
boolean   $value  

[ Top ]

method setClob [line 396]

void setClob( mixed $paramIndex, mixed $clob)



Tags:



Overridden in child classes as:

MSSQLCallableStatement::setClob()
ODBCPreparedStatement::setClob()
OCI8PreparedStatement::setClob()

[ Top ]

method setDate [line 414]

void setDate( int $paramIndex, string $value)



Overridden in child classes as:

MSSQLCallableStatement::setDate()

Parameters:

int   $paramIndex  
string   $value  

[ Top ]

method setDecimal [line 430]

void setDecimal( int $paramIndex, double $value)



Parameters:

int   $paramIndex  
double   $value  

[ Top ]

method setDouble [line 444]

void setDouble( int $paramIndex, double $value)



Parameters:

int   $paramIndex  
double   $value  

[ Top ]

method setFloat [line 458]

void setFloat( int $paramIndex, float $value)



Overridden in child classes as:

MSSQLCallableStatement::setFloat()

Parameters:

int   $paramIndex  
float   $value  

[ Top ]

method setInt [line 472]

void setInt( int $paramIndex, int $value)



Overridden in child classes as:

MSSQLCallableStatement::setInt()

Parameters:

int   $paramIndex  
int   $value  

[ Top ]

method setInteger [line 486]

void setInteger( int $paramIndex, int $value)

Alias for setInt()



Parameters:

int   $paramIndex  
int   $value  

[ Top ]

method setLimit [line 129]

void setLimit( mixed $v)



Tags:

access:  public
see:  PreparedStatement::setLimit()


[ Top ]

method setNull [line 495]

void setNull( int $paramIndex)



Overridden in child classes as:

MSSQLCallableStatement::setNull()
ODBCPreparedStatement::setNull()

Parameters:

int   $paramIndex  

[ Top ]

method setOffset [line 145]

void setOffset( mixed $v)



Tags:

access:  public
see:  PreparedStatement::setOffset()


[ Top ]

method setString [line 505]

void setString( int $paramIndex, string $value)



Overridden in child classes as:

MSSQLCallableStatement::setString()

Parameters:

int   $paramIndex  
string   $value  

[ Top ]

method setTime [line 522]

void setTime( int $paramIndex, string $value)



Overridden in child classes as:

MSSQLCallableStatement::setTime()

Parameters:

int   $paramIndex  
string   $value  

[ Top ]

method setTimestamp [line 539]

void setTimestamp( int $paramIndex, string $value)



Overridden in child classes as:

MSSQLCallableStatement::setTimestamp()

Parameters:

int   $paramIndex  
string   $value  

[ Top ]


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