# DbDeployTask

Extends \Task

Generate SQL script for db using dbdeploy schema version table and delta scripts

<dbdeploy url="mysql:host=localhost;dbname=test" userid="dbdeploy" password="dbdeploy" dir="db" outputfile="">

author | Luke Crouch at SourceForge (http://sourceforge.net)
version | $Id: 2800e23b0fecfddc209dec5c7985e0c8eace0959 $
package | phing.tasks.ext.dbdeploy

### Methods

## Nested adder, adds a set of files (nested fileset attribute).

    addFileSet(\FileSet $fs) : void

### Arguments

#### $fs

`\FileSet`

## Generate the sql for doing/undoing the deployment and write it to a file

    createOutputFile(string $file, boolean $undo = false) : void

### Arguments

#### $file

`string`

#### $undo

`boolean`

## Create the deploy and undo deploy outputfiles

    deploy() : void

## Determine if this patch file need to be deployed (using fileChangeNumber, lastChangeAppliedInDb and $this->checkall)

    fileNeedsToBeRead(integer $fileChangeNumber, string $lastChangeAppliedInDb) : boolean

### Arguments

#### $fileChangeNumber

`integer`

#### $lastChangeAppliedInDb

`string`

### Response

`boolean`

True or false if patch file needs to be deployed

## Generate the sql for doing/undoing this deployment

    generateSql(boolean $undo = false) : string

### Arguments

#### $undo

`boolean`

### Response

`string`

The sql

## Get the numbers of all the patches that are already applied according to the changelog table in the database

    getAppliedChangeNumbers() : array

### Response

`array`

## Get a list of all the patch files in the patch file directory

    getDeltasFilesArray() : array

### Response

`array`

## Returns the textual description of the task

    getDescription() : string

inherited

### Response

`string`

The text description of the task

## Get the number of the last patch applied to the database

    getLastChangeAppliedInDb() : integer|mixed

### Response

`integer|mixed`

The highest patch number that is applied in the db

## Returns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.

    getLocation() : \Location

inherited

### Response

`\Location`

The location object describing the position of this task within the buildfile.

## Returns the owning target of this task.

    getOwningTarget() : \Target

inherited

### Response

`\Target`

The target object that owns this task

## Returns a reference to current project

    getProject() : \Project

inherited

### Response

`\Project`

Reference to current porject object

## Returns a name

    getRegisterSlot(string $slotName) : \RegisterSlot

inherited

### Arguments

#### $slotName

`string`

### Response

`\RegisterSlot`

## Returns the wrapper object for runtime configuration

    getRuntimeConfigurableWrapper() : \RuntimeConfigurable

inherited

### Response

`\RuntimeConfigurable`

The wrapper object used by this task

## Returns the name of task, used only for log messages

    getTaskName() : string

inherited

### Response

`string`

Name of this task

## Returns the name of the task under which it was invoked, usually the XML tagname

    getTaskType() : string

inherited

### Response

`string`

The type of this task (XML Tag)

## Called by the parser to let the task initialize properly.

    init()

inherited

Should throw a BuildException if something goes wrong with the build

This is abstract here, but may not be overloaded by subclasses.

throws |

## Logs a message with the given priority.

    log(string $msg, integer $level = \Project::MSG_INFO) : void

inherited

### Arguments

#### $msg

`string`

The message to be logged.

#### $level

`integer`

The message's priority at this message should have

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

    main()

inherited abstract

Should throw a BuildException if someting goes wrong with the build

This is abstract here. Must be overloaded by real tasks.

## Configure this task if it hasn't been done already.

    maybeConfigure()

inherited

## Perfrom this task

    perform()

inherited

throws |

## Set the appliedBy property

    setAppliedBy(string $appliedBy) : void

### Arguments

#### $appliedBy

`string`

## Set the checkall property

    setCheckAll(boolean $checkall) : void

### Arguments

#### $checkall

`boolean`

## Set the deltaset property

    setDeltaSet(string $deltaSet) : void

### Arguments

#### $deltaSet

`string`

## Sets a textual description of the task

    setDescription(string $desc)

inherited

### Arguments

#### $desc

`string`

The text describing the task

## Set the directory where to find the patchfiles

    setDir(string $dir) : void

### Arguments

#### $dir

`string`

## Set the lastchangetoapply property

    setLastChangeToApply(integer $lastChangeToApply) : void

### Arguments

#### $lastChangeToApply

`integer`

## Sets the location within the buildfile this task occurs. Called by the parser to set location information.

    setLocation(\Location $location)

inherited

### Arguments

#### $location

`\Location`

The location object describing the position of this task within the buildfile.

## Set the outputfile which contains all patch sql statements for this deployment

    setOutputFile(string $outputFile) : void

### Arguments

#### $outputFile

`string`

## Sets the owning target this task belongs to.

    setOwningTarget(\Target $target)

inherited

### Arguments

#### $target

`\Target`

## Set the password for the database connection

    setPassword(string $password) : void

### Arguments

#### $password

`string`

## References the project to the current component.

    setProject(\Project $project) : void

inherited

### Arguments

#### $project

`\Project`

The reference to the current project

## Sets the wrapper object this task should use for runtime configurable elements.

    setRuntimeConfigurableWrapper(\RuntimeConfigurable $wrapper)

inherited

### Arguments

#### $wrapper

`\RuntimeConfigurable`

The wrapper object this task should use

## Sets the name of this task for log messages

    setTaskName(string $name) : string

inherited

### Arguments

#### $name

`string`

### Response

`string`

A string representing the name of this task for log

## Sets the type of the task. Usually this is the name of the XML tag

    setTaskType( $name)

inherited

### Arguments

#### $name

``

## Set the undo outputfile which contains all undo statements for this deployment

    setUndoOutputFile(string $undoOutputFile) : void

### Arguments

#### $undoOutputFile

`string`

## Set the url for the database connection

    setUrl(string $url) : void

### Arguments

#### $url

`string`

## Set the userid for the database connection

    setUserId(string $userid) : void

### Arguments

#### $userid

`string`

## Sort files in the patch files directory (ascending or descending depending on $undo boolean)

    sortFiles(array &$files, boolean $undo) : void

### Arguments

#### $files

`array`

#### $undo

`boolean`

### Properties

## The tablename to use from the database for storing all changes This cannot be changed

    TABLE_NAME : string

static

var |

### Type(s)

`string`

## Connection string for the database connection

    url : string

var |

### Type(s)

`string`

## The userid for the database connection

    userid : string

var |

### Type(s)

`string`

## The password of the database user

    password : string

var |

### Type(s)

`string`

## Path to the directory that holds the database patch files

    dir : string

var |

### Type(s)

`string`

## Output file for performing all database patches of this deployment Contains all the SQL statements that need to be executed

    outputFile : string

var |

### Type(s)

`string`

## Outputfile for undoing the database patches of this deployment Contains all the SQL statements that need to be executed

    undoOutputFile : string

var |

### Type(s)

`string`

## The deltaset that's being used

    deltaSet : string

var |

### Type(s)

`string`

## The number of the last change to apply

    lastChangeToApply : integer

var |

### Type(s)

`integer`

## Contains the object for the DBMS that is used

    dbmsSyntax : object

var |

### Type(s)

`object`

## Array with all change numbers that are applied already

    appliedChangeNumbers : array

var |

### Type(s)

`array`

## Checkall attribute False means dbdeploy will only apply patches that have a higher number than the last patchnumber that was applied True means dbdeploy will apply all changes that aren't applied already (in ascending order)

    checkall : integer

var |

### Type(s)

`integer`

## The value of the 'applied_by' column for each changelog entry

    appliedBy : string

var |

### Type(s)

`string`

## Owning Target object

    target : \Target

inherited

var |

### Type(s)

`\Target`

## Description of the task

    description : string

inherited

var |

### Type(s)

`string`

## Internal taskname (req)

    taskType : string

inherited

var |

### Type(s)

`string`

## Taskname for logger

    taskName : string

inherited

var |

### Type(s)

`string`

## Stored buildfile location

    location : \Location

inherited

var |

### Type(s)

`\Location`

## Wrapper of the task

    wrapper : \RuntimeConfigurable

inherited

var |

### Type(s)

`\RuntimeConfigurable`

## Holds a reference to the project that a project component (a task, a target, etc.) belongs to

    project : \Project

inherited

var | A reference to the current project instance

### Type(s)

`\Project`