phing-tasks-ext-pdo

# Class: PDOSQLExecTask Source Location: /tasks/ext/pdo/PDOSQLExecTask.php
### Class Overview
    ProjectComponent
       |
       --Task
          |
          --PDOTask
             |
             --PDOSQLExecTask
Executes a series of SQL statements on a database using PDO. #### Author(s): Hans Lellelid <hans@xmpl.org> (Phing) Tim Stephenson <tim.stephenson@sybase.com> (Ant) Jeff Martin <jeff@custommonkey.org> (Ant) Michael McCallum <gholam@xtra.co.nz> (Ant) #### Version: $Revision: 557 $ #### Copyright: � 2001,2002 THYRELL. All rights reserved | ### Constants DELIM_NORMAL DELIM_ROW | ### Methods addFileset addText closeFormatters createFormatter createTransaction execSQL getConfiguredFormatters initFormatters isSelectSql main processResults runStatements setDelimiter setDelimiterType setEncoding setFetchmode setOnerror setSrc
### Inherited Variables #### Class: Task Task::$description Task::$location Task::$target Task::$taskName Task::$taskType Task::$wrapper #### Class: ProjectComponent ProjectComponent::$project | ### Inherited Methods #### Class: PDOTask PDOTask::getConnection() Creates a new Connection as using the driver, url, userid and password specified. PDOTask::getLoaderMap() PDOTask::getPassword() Gets the password. PDOTask::getUrl() Gets the url. PDOTask::getUserId() Gets the userId. PDOTask::init() Initialize CreoleTask. PDOTask::isAutocommit() Gets the autocommit. PDOTask::isCaching() PDOTask::setAutocommit() Auto commit flag for database connection; optional, default false. PDOTask::setCaching() Caching loaders / driver. This is to avoid PDOTask::setPassword() Sets the password; required. PDOTask::setUrl() Sets the database connection URL; required. PDOTask::setUserid() Set the user name for the connection; required. PDOTask::setVersion() Sets the version string, execute task only if rdbms version match; optional. #### Class: Task Task::getDescription() Returns the textual description of the task Task::getLocation() Returns the location within the buildfile this task occurs. Used by BuildException to give detailed error messages. Task::getOwningTarget() Returns the owning target of this task. Task::getRegisterSlot() Returns a name Task::getRuntimeConfigurableWrapper() Returns the wrapper object for runtime configuration Task::getTaskName() Returns the name of task, used only for log messages Task::getTaskType() Returns the name of the task under which it was invoked, usually the XML tagname Task::init() Called by the parser to let the task initialize properly. Task::log() Provides a project level log event to the task. Task::main() Called by the project to let the task do it's work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running <em>phing target1 target2</em> will run all tasks in target3 twice. Task::maybeConfigure() Configure this task if it hasn't been done already. Task::perform() Perfrom this task Task::setDescription() Sets a textual description of the task Task::setLocation() Sets the location within the buildfile this task occurs. Called by the parser to set location information. Task::setOwningTarget() Sets the owning target this task belongs to. Task::setRuntimeConfigurableWrapper() Sets the wrapper object this task should use for runtime configurable elements. Task::setTaskName() Sets the name of this task for log messages Task::setTaskType() Sets the type of the task. Usually this is the name of the XML tag #### Class: ProjectComponent ProjectComponent::getProject() Returns a reference to current project ProjectComponent::log() Logs a message with the given priority. ProjectComponent::setProject() References the project to the current component.
### Class Details [line 55] Executes a series of SQL statements on a database using PDO. Statements can either be read in from a text file using the src attribute or from between the enclosing SQL tags. Multiple statements can be provided, separated by semicolons (or the defined delimiter). Individual lines within the statements can be commented using either --, // or REM at the start of the line. The autocommit attribute specifies whether auto-commit should be turned on or off whilst executing the statements. If auto-commit is turned on each statement will be executed and committed. If it is turned off the statements will all be executed as one transaction. The onerror attribute specifies how to proceed when an error occurs during the execution of one of the statements. The possible values are: continue execution, only show the error; stop execution and commit transaction; and abort execution and transaction and fail task. #### Tags:
author: | Hans Lellelid <hans@xmpl.org> (Phing)
author: | Tim Stephenson <tim.stephenson@sybase.com> (Ant)
author: | Jeff Martin <jeff@custommonkey.org> (Ant)
author: | Michael McCallum <gholam@xtra.co.nz> (Ant)
version: | $Revision: 557 $
copyright: | � 2001,2002 THYRELL. All rights reserved
[ Top ] ### Class Methods ### method addFileset [line 160]
`void addFileset( $set)`
Adds a set of files (nested fileset attribute). #### Tags:
access: | public
#### Parameters:
FileSet | $set |
[ Top ] ### method addText [line 153]
`void addText( $sql)`
Set an inline SQL command to execute. NB: Properties are not expanded in this text. #### Tags:
access: | public
#### Parameters:
| $sql |
[ Top ] ### method closeFormatters [line 530]
`void closeFormatters( )`
Run cleanup and close formatters. #### Tags:
access: | protected
[ Top ] ### method createFormatter [line 168]
`PDOSQLExecFormatterElement createFormatter( )`
Creates a new PDOSQLExecFormatterElement for <formatter> element. #### Tags:
access: | public
[ Top ] ### method createTransaction [line 178]
`void createTransaction( )`
Add a SQL transaction to execute #### Tags:
access: | public
[ Top ] ### method execSQL [line 469]
`void execSQL( $sql)`
Exec the sql statement. #### Tags:
throws: | PDOException
access: | protected
#### Parameters:
| $sql |
[ Top ] ### method getConfiguredFormatters [line 507]
`array getConfiguredFormatters( )`
Returns configured PDOResultFormatter objects (which were created from PDOSQLExecFormatterElement objects). #### Tags:
return: | PDOResultFormatter[]
access: | protected
[ Top ] ### method initFormatters [line 519]
`void initFormatters( )`
Initialize the formatters. #### Tags:
access: | protected
[ Top ] ### method isSelectSql [line 459]
`boolean isSelectSql( string $sql)`
Whether the passed-in SQL statement is a SELECT statement. This does a pretty simple match, checking to see if statement starts with 'select' (but not 'select into'). #### Tags:
return: | Whether specified SQL looks like a SELECT query.
access: | protected
#### Parameters:
string | $sql |
[ Top ] ### method main [line 256]
`void main( )`
Load the sql file and then execute it #### Tags:
throws: | BuildException
access: | public
Overrides Task::main() (Called by the project to let the task do it's work. This method may be called more than once, if the task is invoked more than once. For example, if target1 and target2 both depend on target3, then running <em>phing target1 target2</em> will run all tasks in target3 twice.) [ Top ] ### method processResults [line 541]
`void processResults( )`
Passes results from query to any formatters. #### Tags:
access: | protected
[ Top ] ### method runStatements [line 373]
`void runStatements( $reader)`
read in lines and execute them #### Tags:
throws: | PDOException, IOException
access: | public
#### Parameters:
Reader | $reader |
[ Top ] ### method setDelimiter [line 201]
`void setDelimiter( delimiter $delimiter)`
Set the statement delimiter. For example, set this to "go" and delimitertype to "ROW" for Sybase ASE or MS SQL Server. #### Tags:
access: | public
#### Parameters:
delimiter | $delimiter |
[ Top ] ### method setDelimiterType [line 214]
`void setDelimiterType( string $delimiterType)`
Set the Delimiter type for this sql task. The delimiter type takes two values - normal and row. Normal means that any occurence of the delimiter terminate the SQL command whereas with row, only a line containing just the delimiter is recognized as the end of the command. #### Tags:
access: | public
#### Parameters:
string | $delimiterType |
[ Top ] ### method setEncoding [line 189]
`void setEncoding( encoding $encoding)`
Set the file encoding to use on the SQL files read in #### Tags:
access: | public
#### Parameters:
encoding | $encoding | the encoding to use on the files
[ Top ] ### method setFetchmode [line 231]
`void setFetchmode( mixed $mode)`
Sets the fetch mode to use for the PDO resultset. #### Tags:
access: | public
#### Parameters:
mixed | $mode | The PDO fetchmode integer or constant name.
[ Top ] ### method setOnerror [line 223]
`void setOnerror( $action)`
Action to perform when statement fails: continue, stop, or abort optional; default &quot;abort&quot; #### Tags:
access: | public
#### Parameters:
| $action |
[ Top ] ### method setSrc [line 145]
`void setSrc( $srcFile)`
Set the name of the SQL file to be run. Required unless statements are enclosed in the build file #### Tags:
access: | public
#### Parameters:
PhingFile | $srcFile |
[ Top ] ### Class Constants #### DELIM_NORMAL = "normal" [line 70] [ Top ] #### DELIM_ROW = "row" [line 69] [ Top ] Documentation generated on Mon, 19 Oct 2009 10:51:25 +0200 by phpDocumentor 1.4.3