3.4Class Statement

Prepared statements abstraction class

Class Statement

This class represents a statement prepared through the Handle.prepare method which is ready to be excecuted multiple times.

When done, use the Statement.close method to release the resources and refresh the database connection status.

Note: Closing the database handle while the statement is still open and in use may lead to various kind of errors. It's a thing that should be generally avoided.

Properties
affectedIndicates the amount of rows affected by the last query performed on this statement (through the Statement.execute method).
Methods
aexecExecutes a repeated statement.
closeClose this statement.
executeExecutes a repeated statement.
resetResets this statement

Properties

affected

Indicates the amount of rows affected by the last query performed on this statement (through the Statement.execute method).

Will be 0 if none, -1 if unknown, or a positive value if the number of rows can be determined.

Methods

aexec

Executes a repeated statement.

Statement.aexec( [params] )
params The data to be passed to the repeated statement.
ReturnAn instance of Recorset if the query generated a recorset.
Raise
DBIError if the database engine reports an error.

This method executes a statement that has been prepared through the Handle.prepare method. If the prepared statement could return a recordset, it is returned.

Instead of passing the extra parameters to the underlying query, this method sends the value of a single array paramter.

The number of affected rows will be stored also in the Statement.affected property.

See also: Handle, Handle.

close

Close this statement.

Statement.close()

Statements are automatically closed when the statement object is garbage collected, but calling explicitly this helps to reclaim data as soon as it is not necessary anymore.

execute

Executes a repeated statement.

Statement.execute( [...] )
... The data to be passed to the repeated statement.
ReturnAn instance of Recorset if the query generated a recorset.
Raise
DBIError if the database engine reports an error.

This method executes a statement that has been prepared through the Handle.prepare method. If the prepared statement could return a recordset, it is returned.

The number of affected rows will be stored also in the Statement.affected property.

See also: Handle.

reset

Resets this statement

Statement.reset()
Raise
DBIError if the statement cannot be reset.

Some Database engines allow to reset a statement and retry to issue (execute) it without re-creating it anew.

If the database engine doesn't support this feature, a DBIError will be thrown.

Made with http://www.falconpl.org