MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
SchemaDiff.php
Ir para a documentação deste ficheiro.
1
<?php
2
/*
3
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
*
15
* This software consists of voluntary contributions made by many individuals
16
* and is licensed under the LGPL. For more information, see
17
* <http://www.doctrine-project.org>.
18
*/
19
20
namespace
Doctrine\DBAL\Schema
;
21
22
use \Doctrine\DBAL\Platforms\AbstractPlatform;
23
35
class
SchemaDiff
36
{
42
public
$newTables
= array();
43
49
public
$changedTables
= array();
50
56
public
$removedTables
= array();
57
61
public
$newSequences
= array();
62
66
public
$changedSequences
= array();
67
71
public
$removedSequences
= array();
72
76
public
$orphanedForeignKeys
= array();
77
85
public
function
__construct
(
$newTables
= array(),
$changedTables
= array(),
$removedTables
= array())
86
{
87
$this->newTables =
$newTables
;
88
$this->changedTables =
$changedTables
;
89
$this->removedTables =
$removedTables
;
90
}
91
104
public
function
toSaveSql
(
AbstractPlatform
$platform)
105
{
106
return
$this->
_toSql
($platform,
true
);
107
}
108
113
public
function
toSql
(
AbstractPlatform
$platform)
114
{
115
return
$this->
_toSql
($platform,
false
);
116
}
117
123
protected
function
_toSql
(
AbstractPlatform
$platform, $saveMode =
false
)
124
{
125
$sql = array();
126
127
if
($platform->
supportsForeignKeyConstraints
() && $saveMode ==
false
) {
128
foreach
($this->orphanedForeignKeys AS $orphanedForeignKey) {
129
$sql[] = $platform->
getDropForeignKeySQL
($orphanedForeignKey, $orphanedForeignKey->getLocalTableName());
130
}
131
}
132
133
if
($platform->
supportsSequences
() ==
true
) {
134
foreach
($this->changedSequences AS $sequence) {
135
$sql[] = $platform->
getDropSequenceSQL
($sequence);
136
$sql[] = $platform->
getCreateSequenceSQL
($sequence);
137
}
138
139
if
($saveMode ===
false
) {
140
foreach
($this->removedSequences AS $sequence) {
141
$sql[] = $platform->
getDropSequenceSQL
($sequence);
142
}
143
}
144
145
foreach
($this->newSequences AS $sequence) {
146
$sql[] = $platform->
getCreateSequenceSQL
($sequence);
147
}
148
}
149
150
$foreignKeySql = array();
151
foreach
($this->newTables AS $table) {
152
$sql = array_merge(
153
$sql,
154
$platform->
getCreateTableSQL
($table, AbstractPlatform::CREATE_INDEXES)
155
);
156
157
if
($platform->
supportsForeignKeyConstraints
()) {
158
foreach
($table->getForeignKeys() AS $foreignKey) {
159
$foreignKeySql[] = $platform->
getCreateForeignKeySQL
($foreignKey, $table);
160
}
161
}
162
}
163
$sql = array_merge($sql, $foreignKeySql);
164
165
if
($saveMode ===
false
) {
166
foreach
($this->removedTables AS $table) {
167
$sql[] = $platform->
getDropTableSQL
($table);
168
}
169
}
170
171
foreach
($this->changedTables AS $tableDiff) {
172
$sql = array_merge($sql, $platform->
getAlterTableSQL
($tableDiff));
173
}
174
175
return
$sql;
176
}
177
}
Doctrine\DBAL\Platforms\AbstractPlatform
Definição
AbstractPlatform.php:47
Doctrine\DBAL\Platforms\AbstractPlatform\getAlterTableSQL
getAlterTableSQL(TableDiff $diff)
Definição
AbstractPlatform.php:1001
Doctrine\DBAL\Platforms\AbstractPlatform\getDropForeignKeySQL
getDropForeignKeySQL($foreignKey, $table)
Definição
AbstractPlatform.php:734
Doctrine\DBAL\Platforms\AbstractPlatform\supportsForeignKeyConstraints
supportsForeignKeyConstraints()
Definição
AbstractPlatform.php:1837
Doctrine\DBAL\Platforms\AbstractPlatform\getCreateSequenceSQL
getCreateSequenceSQL(\Doctrine\DBAL\Schema\Sequence $sequence)
Definição
AbstractPlatform.php:874
Doctrine\DBAL\Platforms\AbstractPlatform\getDropSequenceSQL
getDropSequenceSQL($sequence)
Definição
AbstractPlatform.php:1665
Doctrine\DBAL\Platforms\AbstractPlatform\supportsSequences
supportsSequences()
Definição
AbstractPlatform.php:1760
Doctrine\DBAL\Platforms\AbstractPlatform\getCreateTableSQL
getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
Definição
AbstractPlatform.php:755
Doctrine\DBAL\Platforms\AbstractPlatform\getCreateForeignKeySQL
getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table)
Definição
AbstractPlatform.php:982
Doctrine\DBAL\Platforms\AbstractPlatform\getDropTableSQL
getDropTableSQL($table)
Definição
AbstractPlatform.php:682
Doctrine\DBAL\Schema\SchemaDiff
Definição
SchemaDiff.php:36
Doctrine\DBAL\Schema\SchemaDiff\$newSequences
$newSequences
Definição
SchemaDiff.php:61
Doctrine\DBAL\Schema\SchemaDiff\$orphanedForeignKeys
$orphanedForeignKeys
Definição
SchemaDiff.php:76
Doctrine\DBAL\Schema\SchemaDiff\$removedSequences
$removedSequences
Definição
SchemaDiff.php:71
Doctrine\DBAL\Schema\SchemaDiff\$changedSequences
$changedSequences
Definição
SchemaDiff.php:66
Doctrine\DBAL\Schema\SchemaDiff\$removedTables
$removedTables
Definição
SchemaDiff.php:56
Doctrine\DBAL\Schema\SchemaDiff\__construct
__construct($newTables=array(), $changedTables=array(), $removedTables=array())
Definição
SchemaDiff.php:85
Doctrine\DBAL\Schema\SchemaDiff\toSaveSql
toSaveSql(AbstractPlatform $platform)
Definição
SchemaDiff.php:104
Doctrine\DBAL\Schema\SchemaDiff\$newTables
$newTables
Definição
SchemaDiff.php:42
Doctrine\DBAL\Schema\SchemaDiff\toSql
toSql(AbstractPlatform $platform)
Definição
SchemaDiff.php:113
Doctrine\DBAL\Schema\SchemaDiff\_toSql
_toSql(AbstractPlatform $platform, $saveMode=false)
Definição
SchemaDiff.php:123
Doctrine\DBAL\Schema\SchemaDiff\$changedTables
$changedTables
Definição
SchemaDiff.php:49
Doctrine\DBAL\Schema
Definição
AbstractAsset.php:22
classes
extensions
doctrine-dbal
Doctrine
DBAL
Schema
SchemaDiff.php
Gerado por
1.10.0