classes/phing/tasks/ext/pdo/PDOSQLExecTask.php
\PDOSQLExecTask
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.
- Extends from
- \PDOTask
- author
- Hans Lellelid
(Phing) - author
- Jeff Martin
(Ant) - author
- Michael McCallum
(Ant) - author
- Tim Stephenson
(Ant) - copyright
- 2001,2002 THYRELL. All rights reserved
- package
- phing.tasks.ext.pdo
- version
- $Revision: 1274 $
Constants
Properties

string
$delimiter= ';'
SQL Statement delimiter (for parsing files)
;Details- Type
- string

$delimiterType= 'normal'
The delimiter type indicating whether the delimiter will only be recognized on a line by itself
normalDetails- Type

$encoding= 'null'
Encoding to use when reading SQL statements from a file
nullDetails- Type

array
$formatters= 'array'
Formatter elements.
PDOSQLExecFormatterElement[]arrayDetails- Type
- array

int
$goodSql= '0'
Count of how many statements were executed successfully.
0Details- Type
- int
Methods

addFilelist(
$list
)
:
| Name | Type | Description |
|---|---|---|
| $list |

addFileset(
$set
)
:
| Name | Type | Description |
|---|---|---|
| $set |

addText(
$sql
)
:
NB: Properties are not expanded in this text.
| Name | Type | Description |
|---|---|---|
| $sql |

createFormatter(
)
:
\PDOSQLExecFormatterElement| Type | Description |
|---|---|
| \PDOSQLExecFormatterElement |

getConfiguredFormatters(
)
:
array| Type | Description |
|---|---|
| array |

getDefaultOutput(
)
:
\Writer| Type | Description |
|---|---|
| \Writer |

isSelectSql(
string $sql
)
:
booleanThis does a pretty simple match, checking to see if statement starts with 'select' (but not 'select into').
| Name | Type | Description |
|---|---|---|
| $sql | string |
| Type | Description |
|---|---|
| boolean |

runStatements(
$reader
)
:
| Name | Type | Description |
|---|---|---|
| $reader |
- throws
- IOException

setDelimiter(
$delimiter
)
:
For example, set this to "go" and delimitertype to "ROW" for Sybase ASE or MS SQL Server.
| Name | Type | Description |
|---|---|---|
| $delimiter | delimiter |

setDelimiterType(
string $delimiterType
)
:
| Name | Type | Description |
|---|---|---|
| $delimiterType | string |

setEncoding(
\encoding $encoding
)
:
| Name | Type | Description |
|---|---|---|
| $encoding | \encoding | the encoding to use on the files |

setFetchmode(
mixed $mode
)
:
| Name | Type | Description |
|---|---|---|
| $mode | mixed | The PDO fetchmode integer or constant name. |

setOnerror(
$action
)
:
| Name | Type | Description |
|---|---|---|
| $action |