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.
| author |
Hans Lellelid hans@xmpl.org (Phing) |
|---|---|
| author |
Jeff Martin jeff@custommonkey.org (Ant) |
| author |
Michael McCallum gholam@xtra.co.nz (Ant) |
| author |
Tim Stephenson tim.stephenson@sybase.com (Ant) |
| package |
phing.tasks.ext.pdo |
| version |
$Id: 182105a0849f432bb5d0d91d39ed1c57e1575ff6 $ |
setSrc(\PhingFile $srcFile)
addText($sql)
NB: Properties are not expanded in this text.
addFilelist(\FileList $list)
createFormatter() : \PDOSQLExecFormatterElement
createTransaction()
setEncoding($encoding)
setDelimiter($delimiter)
For example, set this to "go" and delimitertype to "ROW" for Sybase ASE or MS SQL Server.
getDelimiter() : string
string
setDelimiterType(string $delimiterType)
string
setOnerror($action)
setFetchmode(mixed $mode)
mixedThe PDO fetchmode integer or constant name.
main()
Should throw a BuildException if someting goes wrong with the build
This is abstract here. Must be overloaded by real tasks.
runStatements(\Reader $reader)
isSelectSql(string $sql) : boolean
This does a pretty simple match, checking to see if statement starts with 'select' (but not 'select into').
string
booleanWhether specified SQL looks like a SELECT query.
execSQL($sql)
| throws | |
|---|---|
getConfiguredFormatters() : array
arrayPDOResultFormatter[]
initFormatters()
closeFormatters()
processResults()
| throws |
|---|
closeConnection()
init()
Should throw a BuildException if something goes wrong with the build
This is abstract here, but may not be overloaded by subclasses.
| throws |
|---|
setCaching(mixed $enable)
mixed
setUrl($url)
setPassword($password)
setAutocommit($autocommit)
setVersion($version)
getLoaderMap()
getConnection() : \Connection
The calling method is responsible for closing the connection.
| throws |
if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load. |
|---|
\Connectionthe newly created connection.
isCaching($value)
isAutocommit() : \Returns
\Returnsa boolean
getUrl() : \Returns
\Returnsa String
getUserId() : \Returns
\Returnsa String
setUserid($userId)
getPassword() : \Returns
\Returnsa String
setOwningTarget(\Target $target)
getOwningTarget() : \Target
getTaskName() : string
stringName of this task
setTaskName(string $name) : string
string
stringA string representing the name of this task for log
getTaskType() : string
stringThe type of this task (XML Tag)
setTaskType($name)
getRegisterSlot(string $slotName)
string
log(string $msg, integer $level = \Project::MSG_INFO)
stringThe message to be logged.
integerThe message's priority at this message should have
setDescription(string $desc)
stringThe text describing the task
getDescription() : string
stringThe text description of the task
getLocation() : \Location
setLocation(\Location $location)
getRuntimeConfigurableWrapper() : \RuntimeConfigurable
setRuntimeConfigurableWrapper(\RuntimeConfigurable $wrapper)
maybeConfigure()
perform()
setProject(\Project $project)
getProject() : \Project
DELIM_ROW
DELIM_NORMAL
DELIM_NONE
goodSql : int
| var |
|---|
int
totalSql : int
| var |
|---|
int
conn : \PDO
| var |
|---|
\PDO
filesets : array
| var |
FileSet[] |
|---|
array
filelists : array
| var |
FileList[] |
|---|
array
formatters : array
| var |
PDOSQLExecFormatterElement[] |
|---|
array
statement : \PDOStatement
| var |
|---|
\PDOStatement
sqlCommand : string
| var |
|---|
string
transactions :
delimiter : string
| var |
|---|
string
delimiterType :
onError :
encoding :
fetchMode : int
| var |
|---|
int
caching :
autocommit :
url :
userId :
password :
rdbms :
description : string
| var |
|---|
string
taskType : string
| var |
|---|
string
taskName : string
| var |
|---|
string
project : \Project