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

Class: Statement

Source Location: /creole/Statement.php

Interface Overview


Class that represents a SQL statement.


Author(s):

Version:

  • $Revision: 1.17 $

Methods



Class Details

[line 36]
Class that represents a SQL statement.

This class is very generic and has no driver-specific implementations. In fact, it wouldn't be possible to have driver-specific classes, since PHP doesn't support multiple inheritance. I.e. you couldn't have MySQLPreparedStatement that extended both the abstract PreparedStatement class and the MySQLStatement class. In Java this isn't a concern since PreparedStatement is an interface, not a class.




Tags:

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


[ Top ]


Class Methods


method close [line 77]

void close( )

Free resources associated with this statement.

Some drivers will need to implement this method to free database result resources.




Tags:

access:  public


[ Top ]

method execute [line 89]

boolean execute( mixed $sql, [int $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.




Tags:

return:  True if it is a result set, false if not or if no more results (this is identical to JDBC return val).
access:  public
throws:  SQLException


Parameters:

int   $fetchmode   Fetchmode (only applies to queries).

[ Top ]

method executeQuery [line 115]

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

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



Tags:

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


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

[ Top ]

method executeUpdate [line 124]

int executeUpdate( string $sql)

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.


Parameters:

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

[ Top ]

method getConnection [line 145]

Connection getConnection( )

Gets the db Connection that created this statement.



Tags:

access:  public


[ Top ]

method getLimit [line 51]

int getLimit( )

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



Tags:

access:  public


[ Top ]

method getMoreResults [line 139]

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




Tags:

return:  True if there is another result set, otherwise false.
access:  public


[ Top ]

method getOffset [line 68]

int getOffset( )

Returns the start row.

Offset only applies when Limit is set!




Tags:

access:  public


[ Top ]

method getResultSet [line 98]

RestultSet getResultSet( )

Get result set.

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




Tags:

return:  (or null if none)
access:  public


[ Top ]

method getUpdateCount [line 105]

int getUpdateCount( )

Get update count.



Tags:

return:  Number of records affected, or
  1. null
if not applicable.
access:  public


[ Top ]

method setLimit [line 45]

void setLimit( int $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).




Tags:

access:  public


Parameters:

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

[ Top ]

method setOffset [line 61]

void setOffset( int $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!




Tags:

access:  public


Parameters:

int   $v  

[ Top ]


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