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.
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>.
23 require_once 'phar://'.__FILE__.'/Doctrine/Common/ClassLoader.php';
25 $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', 'phar://'.__FILE__);
26 $classLoader->register();
28 $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', 'phar://'.__FILE__);
29 $classLoader->register();
31 $classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'phar://'.__FILE__);
32 $classLoader->register();
34 $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
35 'dialog' => new \Symfony\Component\Console\Helper\DialogHelper(),
38 $cli = new \Symfony\Component\Console\Application('Doctrine Migrations', \Doctrine\DBAL\Migrations\MigrationsVersion::VERSION);
39 $cli->setCatchExceptions(true);
40 $cli->setHelperSet($helperSet);
41 $cli->addCommands(array(
42 // Migrations Commands
43 new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
44 new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
45 new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
46 new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
47 new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
48 new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand()
51 $input = file_exists('migrations-input.php')
52 ? include('migrations-input.php')
55 $output = file_exists('migrations-output.php')
56 ? include('migrations-output.php')
59 $cli->run($input, $output);
61 __HALT_COMPILER(); ?>
\r
62 \83,
\0\0¤
\0\0\0\11\0\0\0\ 1\0\0\0\0\0\0\0\0\0;
\0\0\0Doctrine/DBAL/Migrations/IrreversibleMigrationException.php¨
\ 5\0\0\99ÈÏL¨
\ 5\0\0\82üÊܶ
\ 1\0\0\0\0\0\04
\0\0\0Doctrine/DBAL/Migrations/AbortMigrationException.phpm
\0\0\0\99ÈÏLm
\0\0\0°ß
\ e\9c¶
\ 1\0\0\0\0\0\03
\0\0\0Doctrine/DBAL/Migrations/SkipMigrationException.phpl
\0\0\0\99ÈÏLl
\0\0\0\16\1dTŶ
\ 1\0\0\0\0\0\0.
\0\0\0Doctrine/DBAL/Migrations/AbstractMigration.phpå
\11\0\0\99ÈÏLå
\11\0\0¢
\9dé`¶
\ 1\0\0\0\0\0\0/
\0\0\0Doctrine/DBAL/Migrations/MigrationException.phpÈ
\0\0\99ÈÏLÈ
\0\0(Shz¶
\ 1\0\0\0\0\0\0&
\0\0\0Doctrine/DBAL/Migrations/Migration.php
\16\0\0\99ÈÏL
\16\0\0Í~®«¶
\ 1\0\0\0\0\0\08
\0\0\0Doctrine/DBAL/Migrations/Configuration/Configuration.php"7
\0\0\99ÈÏL"7
\0\0\15pë
\90¶
\ 1\0\0\0\0\0\0;
\0\0\0Doctrine/DBAL/Migrations/Configuration/XmlConfiguration.php
\9b \0\0\99ÈÏL
\9b \0\0ëZ÷
\1d¶
\ 1\0\0\0\0\0\0<
\0\0\0Doctrine/DBAL/Migrations/Configuration/YamlConfiguration.php¢
\0\0\99ÈÏL¢
\0\0>x7¾¶
\ 1\0\0\0\0\0\0D
\0\0\0Doctrine/DBAL/Migrations/Configuration/AbstractFileConfiguration.php
\v\0\0\99ÈÏL
\v\0\0\9fMÿ
\17¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Migrations/OutputWriter.php
\ 3\a\0\0\99ÈÏL
\ 3\a\0\04
\97£4¶
\ 1\0\0\0\0\0\0$
\0\0\0Doctrine/DBAL/Migrations/Version.phpÏ&
\0\0\99ÈÏLÏ&
\0\0v
\8cM}¶
\ 1\0\0\0\0\0\0.
\0\0\0Doctrine/DBAL/Migrations/MigrationsVersion.php8
\ 4\0\0\99ÈÏL8
\ 4\0\0¢
\11R£¶
\ 1\0\0\0\0\0\0>
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/DiffCommand.phpÌ
\ f\0\0\99ÈÏLÌ
\ f\0\0£4&
\16¶
\ 1\0\0\0\0\0\0B
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/AbstractCommand.phpâ
\15\0\0\99ÈÏLâ
\15\0\0*T\j¶
\ 1\0\0\0\0\0\0B
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/GenerateCommand.phpã
\ f\0\0\99ÈÏLã
\ f\0\0\ 1~Ò
\1a¶
\ 1\0\0\0\0\0\0A
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/VersionCommand.php
\a\10\0\0\99ÈÏL
\a\10\0\0í±
\13§¶
\ 1\0\0\0\0\0\0A
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/ExecuteCommand.php
\96\10\0\0\99ÈÏL
\96\10\0\0U
\11üI¶
\ 1\0\0\0\0\0\0@
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/StatusCommand.php÷
\15\0\0\99ÈÏL÷
\15\0\0ñe
\8f-¶
\ 1\0\0\0\0\0\0A
\0\0\0Doctrine/DBAL/Migrations/Tools/Console/Command/MigrateCommand.php7
\12\0\0\99ÈÏL7
\12\0\0a±é¹¶
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/DBAL/DBALException.php
\f
64 \0\0\8c^Ñ<¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Driver/PDOOracle/Driver.php¤
66 \0\0ýós&¶
\ 1\0\0\0\0\0\0-
\0\0\0Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
\ 3\r\0\0\99ÈÏL
\ 3\r\0\0<t
\96\0¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php®.
\0\0\99ÈÏL®.
\0\0Á
\e¥3¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php7
\ 4\0\0\99ÈÏL7
\ 4\0\0Ç~Þò¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php®
\ e\0\0\99ÈÏL®
\ e\0\0üh
\83$¶
\ 1\0\0\0\0\0\0%
\0\0\0Doctrine/DBAL/Driver/PDOStatement.php
\v\ 5\0\0\99ÈÏL
\v\ 5\0\0\87F
\17Á¶
\ 1\0\0\0\0\0\0(
\0\0\0Doctrine/DBAL/Driver/PDOMsSql/Driver.phpÒ
\0\0\99ÈÏLÒ
\0\0\81kX)¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Driver/PDOMsSql/Connection.php|
\ 6\0\0\99ÈÏL|
\ 6\0\0P{1
\13¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/DBAL/Driver/Statement.php
\9b%
\0\0\99ÈÏL
\9b%
\0\0,¿i
\80¶
\ 1\0\0\0\0\0\0(
\0\0\0Doctrine/DBAL/Driver/PDOPgSql/Driver.php
\8c\ 6\0\0\99ÈÏL
\8c\ 6\0\0§
\7f\9cZ¶
\ 1\0\0\0\0\0\0&
\0\0\0Doctrine/DBAL/Driver/PDOConnection.php
\12\ 6\0\0\99ÈÏL
\12\ 6\0\0Q0
\12Ô¶
\ 1\0\0\0\0\0\0&
\0\0\0Doctrine/DBAL/Driver/PDOIbm/Driver.phpN
\ f\0\0\99ÈÏLN
\ f\0\0SPuo¶
\ 1\0\0\0\0\0\0(
\0\0\0Doctrine/DBAL/Driver/PDOMySql/Driver.php?
\v\0\0\99ÈÏL?
\v\0\0£°¤¿¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php¬
\0\0\99ÈÏL¬
\0\0·
\15ܪ¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Driver/PDOSqlite/Driver.php§
\ e\0\0\99ÈÏL§
\ e\0\0ÓÖV
\80¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/DBAL/Driver/OCI8/OCI8Exception.php«
\ 4\0\0\99ÈÏL«
\ 4\0\0J¢Ù®¶
\ 1\0\0\0\0\0\0$
\0\0\0Doctrine/DBAL/Driver/OCI8/Driver.php?
\v\0\0\99ÈÏL?
\v\0\0ó
\ fÀ»¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
\ 4\e\0\0\99ÈÏL
\ 4\e\0\0µR
\14¦¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
\13\ f\0\0\99ÈÏL
\13\ f\0\0Ïç
\88\13¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Driver/Connection.phpé
\ 5\0\0\99ÈÏLé
\ 5\0\0\8fkV«¶
\ 1\0\0\0\0\0\0\18\0\0\0Doctrine/DBAL/Events.phpù
\ 4\0\0\99ÈÏLù
\ 4\0\0Â
\0p
\13¶
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/DBAL/DriverManager.phpË
\17\0\0\99ÈÏLË
\17\0\0dÄ< ¶
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/DBAL/Configuration.phpp
\b\0\0\99ÈÏLp
\b\0\0¦êMo¶
\ 1\0\0\0\0\0\0\e\0\0\0Doctrine/DBAL/Statement.php
\ 4\1d\0\0\99ÈÏL
\ 4\1d\0\0uÒËÛ¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/DBAL/Schema/MySqlSchemaManager.php:
\19\0\0\99ÈÏL:
\19\0\0#÷r
\80¶
\ 1\0\0\0\0\0\00
\0\0\0Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
\97$
\0\0\99ÈÏL
\97$
\0\0ÔÛ
\8bó¶
\ 1\0\0\0\0\0\0\1d\0\0\0Doctrine/DBAL/Schema/View.phpF
\ 6\0\0\99ÈÏLF
\ 6\0\0\8d.ú±¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Schema/DB2SchemaManager.php=
\19\0\0\99ÈÏL=
\19\0\0Ó
\93\17»¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Schema/SqliteSchemaManager.php÷
\16\0\0\99ÈÏL÷
\16\0\0\1f\7fU´¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Schema/Comparator.phpÁ3
\0\0\99ÈÏLÁ3
\0\0\8eÖÜ
67 ¶
\ 1\0\0\0\0\0\0\1e\0\0\0Doctrine/DBAL/Schema/Index.php
\80\14\0\0\99ÈÏL
\80\14\0\0Ô&o!¶
\ 1\0\0\0\0\0\0.
\0\0\0Doctrine/DBAL/Schema/AbstractSchemaManager.phpKV
\0\0\99ÈÏLKV
\0\0,:
\b\89¶
\ 1\0\0\0\0\0\0&
\0\0\0Doctrine/DBAL/Schema/AbstractAsset.phpþ
\f\0\0\99ÈÏLþ
\f\0\0 T
\1eK¶
\ 1\0\0\0\0\0\0%
\0\0\0Doctrine/DBAL/Schema/SchemaConfig.phpC
\b\0\0\99ÈÏLC
\b\0\0Ù>ƶ
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/DBAL/Schema/Column.php§
\1c\0\0\99ÈÏL§
\1c\0\0+W
\8a\92¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Schema/Constraint.phpO
\ 5\0\0\99ÈÏLO
\ 5\0\0\82:
\87¦¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Schema/SchemaDiff.phpÿ
\14\0\0\99ÈÏLÿ
\14\0\0~'
\9a×¶
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/DBAL/Schema/Schema.php3"
\0\0\99ÈÏL3"
\0\0"
\ e$V¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/DBAL/Schema/MsSqlSchemaManager.php!
\16\0\0\99ÈÏL!
\16\0\0\85@á
\84¶
\ 1\0\0\0\0\0\0(
\0\0\0Doctrine/DBAL/Schema/Visitor/Visitor.php*
\0\0\99ÈÏL*
\0\0D
\9di&¶
\ 1\0\0\0\0\0\09
\0\0\0Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.phpj
\ f\0\0\99ÈÏLj
\ f\0\0à
\12妦
\ 1\0\0\0\0\0\07
\0\0\0Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php¡
\ e\0\0\99ÈÏL¡
\ e\0\00ý
\aé¶
\ 1\0\0\0\0\0\0-
\0\0\0Doctrine/DBAL/Schema/ForeignKeyConstraint.phpÚ
\ e\0\0\99ÈÏLÚ
\ e\0\0}
\8fW¼¶
\ 1\0\0\0\0\0\0\1e\0\0\0Doctrine/DBAL/Schema/Table.php`C
\0\0\99ÈÏL`C
\0\0\ 6ï»P¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/DBAL/Schema/TableDiff.php^
\ e\0\0\99ÈÏL^
\ e\0\0Ê
\16\12¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Schema/OracleSchemaManager.php6$
\0\0\99ÈÏL6$
\0\0äÍ
\1cG¶
\ 1\0\0\0\0\0\0!
\0\0\0Doctrine/DBAL/Schema/Sequence.php
\92\b\0\0\99ÈÏL
\92\b\0\0LöÜk¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Schema/ColumnDiff.php
\1d\a\0\0\99ÈÏL
\1d\a\0\0ûÏ'
\8b¶
\ 1\0\0\0\0\0\0(
\0\0\0Doctrine/DBAL/Schema/SchemaException.phpt
\ f\0\0\99ÈÏLt
\ f\0\0ή!
\86¶
\ 1\0\0\0\0\0\0\1a\0\0\0Doctrine/DBAL/LockMode.phpä
\ 5\0\0\99ÈÏLä
\ 5\0\0jWW̶
\ 1\0\0\0\0\0\0\18\0\0\0Doctrine/DBAL/Driver.php=
69 \0\01
\eô]¶
\ 1\0\0\0\0\0\0.
\0\0\0Doctrine/DBAL/Platforms/PostgreSqlPlatform.php Y
\0\0\99ÈÏL Y
\0\0®
\8cv¡¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Platforms/MsSqlPlatform.php
\97M
\0\0\99ÈÏL
\97M
\0\0¼å>0¶
\ 1\0\0\0\0\0\0*
\0\0\0Doctrine/DBAL/Platforms/OraclePlatform.php
\83V
\0\0\99ÈÏL
\83V
\0\0|
\1fª
\9d¶
\ 1\0\0\0\0\0\0'
\0\0\0Doctrine/DBAL/Platforms/DB2Platform.php
\eA
\0\0\99ÈÏL
\eA
\0\0\E1ß¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/DBAL/Platforms/MySqlPlatform.php
\9dM
\0\0\99ÈÏL
\9dM
\0\0¥
\936¶
\ 1\0\0\0\0\0\0,
\0\0\0Doctrine/DBAL/Platforms/AbstractPlatform.phpýî
\0\0\99ÈÏLýî
\0\0X
\9aò
\88¶
\ 1\0\0\0\0\0\0*
\0\0\0Doctrine/DBAL/Platforms/SqlitePlatform.phpF8
\0\0\99ÈÏLF8
\0\0E
\1f\rT¶
\ 1\0\0\0\0\0\0\1d\0\0\0Doctrine/DBAL/README.markdown
\0\0\0\0\99ÈÏL
\0\0\0\0\0\0\0\0¶
\ 1\0\0\0\0\0\0\19\0\0\0Doctrine/DBAL/Version.phpó
\a\0\0\99ÈÏLó
\a\0\0\ 5|!
\92¶
\ 1\0\0\0\0\0\0%
\0\0\0Doctrine/DBAL/ConnectionException.php
\0\b\0\0\99ÈÏL
\0\b\0\0¾óíC¶
\ 1\0\0\0\0\0\0\1c\0\0\0Doctrine/DBAL/Connection.php£{
\0\0\99ÈÏL£{
\0\0÷ªË
\1f¶
\ 1\0\0\0\0\0\0'
\0\0\0Doctrine/DBAL/Logging/EchoSQLLogger.phpN
\a\0\0\99ÈÏLN
\a\0\0¾
\13N¦
\ 1\0\0\0\0\0\0$
\0\0\0Doctrine/DBAL/Logging/DebugStack.php
\9f\b\0\0\99ÈÏL
\9f\b\0\0}
\ 2ª
\12¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Logging/SQLLogger.php§
\a\0\0\99ÈÏL§
\a\0\05õ
\90 ¶
\ 1\0\0\0\0\0\05
\0\0\0Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
\1c\12\0\0\99ÈÏL
\1c\12\0\0G:
\8d¨¶
\ 1\0\0\0\0\0\05
\0\0\0Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php/
\f\0\0\99ÈÏL/
\f\0\0÷Ï9R¶
\ 1\0\0\0\0\0\07
\0\0\0Doctrine/DBAL/Tools/Console/Helper/ConnectionHelper.phpv
\b\0\0\99ÈÏLv
\b\0\04
\18ás¶
\ 1\0\0\0\0\0\0'
\0\0\0Doctrine/DBAL/Types/VarDateTimeType.phpÔ
\b\0\0\99ÈÏLÔ
\b\0\0wá3ì¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Types/IntegerType.phpª
\ 6\0\0\99ÈÏLª
\ 6\0\0 l6
\92¶
\ 1\0\0\0\0\0\0 \0\0\0Doctrine/DBAL/Types/DateType.phpÊ
\a\0\0\99ÈÏLÊ
\a\0\0òEÇe¶
\ 1\0\0\0\0\0\0\1c\0\0\0Doctrine/DBAL/Types/Type.php
\ 6\1c\0\0\99ÈÏL
\ 6\1c\0\0Â,do¶
\ 1\0\0\0\0\0\0!
\0\0\0Doctrine/DBAL/Types/FloatType.phpz
\a\0\0\99ÈÏLz
\a\0\0~[e
\91¶
\ 1\0\0\0\0\0\0$
\0\0\0Doctrine/DBAL/Types/SmallIntType.php
\85\ 6\0\0\99ÈÏL
\85\ 6\0\0G9#k¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/DBAL/Types/BigIntType.phpû
\ 5\0\0\99ÈÏLû
\ 5\0\0>
\1e\9fõ¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/DBAL/Types/StringType.phpY
\ 6\0\0\99ÈÏLY
\ 6\0\0(¤.G¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/DBAL/Types/ObjectType.phpñ
\ 3\0\0\99ÈÏLñ
\ 3\0\0M(
\ 3\1d¶
\ 1\0\0\0\0\0\0&
\0\0\0Doctrine/DBAL/Types/DateTimeTzType.php
\7f\f\0\0\99ÈÏL
\7f\f\0\0\96ç}
\10¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/DBAL/Types/ConversionException.php±
\a\0\0\99ÈÏL±
\a\0\0¢Gf[¶
\ 1\0\0\0\0\0\0$
\0\0\0Doctrine/DBAL/Types/DateTimeType.phpë
\a\0\0\99ÈÏLë
\a\0\0\ 3ìÝ
\81¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Types/DecimalType.php
\1f\ 6\0\0\99ÈÏL
\1f\ 6\0\0\9cµ
\a\91¶
\ 1\0\0\0\0\0\0 \0\0\0Doctrine/DBAL/Types/TextType.php
\7f\a\0\0\99ÈÏL
\7f\a\0\0ªúæ@¶
\ 1\0\0\0\0\0\0!
\0\0\0Doctrine/DBAL/Types/ArrayType.phpÊ
\a\0\0\99ÈÏLÊ
\a\0\0§´ùï¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/DBAL/Types/BooleanType.php
\10\a\0\0\99ÈÏL
\10\a\0\0\9f<4
\89¶
\ 1\0\0\0\0\0\0 \0\0\0Doctrine/DBAL/Types/TimeType.php5
\b\0\0\99ÈÏL5
\b\0\0Ù»
\11¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/DBAL/Event/ConnectionEventArgs.phpõ
\b\0\0\99ÈÏLõ
\b\0\0\ 1±5
\90¶
\ 1\0\0\0\0\0\02
\0\0\0Doctrine/DBAL/Event/Listeners/MysqlSessionInit.phpO
\0\0\99ÈÏLO
\0\0¤â¿9¶
\ 1\0\0\0\0\0\03
\0\0\0Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
\98\v\0\0\99ÈÏL
\98\v\0\01?
\91\16¶
\ 1\0\0\0\0\0\0\1d\0\0\0Doctrine/Common/EventArgs.php#
71 \0\0to·
\a¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/Common/CommonException.phpq
\ 4\0\0\99ÈÏLq
\ 4\0\0(|
\1ck¶
\ 1\0\0\0\0\0\00
\0\0\0Doctrine/Common/Annotations/AnnotationReader.php
\b"
\0\0\99ÈÏL
\b"
\0\0
72 6
\13ÿ¶
\ 1\0\0\0\0\0\03
\0\0\0Doctrine/Common/Annotations/AnnotationException.php
\90\a\0\0\99ÈÏL
\90\a\0\0ø=?
\8b¶
\ 1\0\0\0\0\0\0&
\0\0\0Doctrine/Common/Annotations/Parser.php£=
\0\0\99ÈÏL£=
\0\03¾
\9aS¶
\ 1\0\0\0\0\0\0%
\0\0\0Doctrine/Common/Annotations/Lexer.phpª
\12\0\0\99ÈÏLª
\12\0\0Snôÿ¶
\ 1\0\0\0\0\0\0*
\0\0\0Doctrine/Common/Annotations/Annotation.phpö
\0\0\99ÈÏLö
\0\0@ãÔ
\18¶
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/Common/ClassLoader.php
\ f"
\0\0\99ÈÏL
\ f"
\0\0\9b:à@¶
\ 1\0\0\0\0\0\0/
\0\0\0Doctrine/Common/Collections/ArrayCollection.php .
\0\0\99ÈÏL .
\0\0ùj
\eë¶
\ 1\0\0\0\0\0\0*
\0\0\0Doctrine/Common/Collections/Collection.phpZ
\0\0\99ÈÏLZ
\0\0\9f´
\80\80¶
\ 1\0\0\0\0\0\0\e\0\0\0Doctrine/Common/Version.phpõ
\a\0\0\99ÈÏLõ
\a\0\0¸Ó/\¶
\ 1\0\0\0\0\0\0%
\0\0\0Doctrine/Common/Cache/XcacheCache.phpç
\v\0\0\99ÈÏLç
\v\0\0&
\ 22Ͷ
\ 1\0\0\0\0\0\0$
\0\0\0Doctrine/Common/Cache/ArrayCache.php'
\0\0\99ÈÏL'
\0\0ï::b¶
\ 1\0\0\0\0\0\0'
\0\0\0Doctrine/Common/Cache/MemcacheCache.phpû
\f\0\0\99ÈÏLû
\f\0\0rü6
\80¶
\ 1\0\0\0\0\0\0\1f\0\0\0Doctrine/Common/Cache/Cache.php
\13
74 \0\0±Ó\O¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/Common/Cache/ApcCache.phpA
\0\0\99ÈÏLA
\0\0Y
\84Á*¶
\ 1\0\0\0\0\0\0'
\0\0\0Doctrine/Common/Cache/AbstractCache.php1
\18\0\0\99ÈÏL1
\18\0\0L»
\8d0¶
\ 1\0\0\0\0\0\0\1e\0\0\0Doctrine/Common/Util/Debug.php
\ 2\13\0\0\99ÈÏL
\ 2\13\0\0Í;º`¶
\ 1\0\0\0\0\0\0"
\0\0\0Doctrine/Common/Util/Inflector.php;
76 \0\0;%ë
\90¶
\ 1\0\0\0\0\0\0)
\0\0\0Doctrine/Common/NotifyPropertyChanged.phpª
\ 6\0\0\99ÈÏLª
\ 6\0\0\1aÃnF¶
\ 1\0\0\0\0\0\0+
\0\0\0Doctrine/Common/PropertyChangedListener.php
\89\a\0\0\99ÈÏL
\89\a\0\0©ï
\86î¶
\ 1\0\0\0\0\0\0 \0\0\0Doctrine/Common/EventManager.php,
\13\0\0\99ÈÏL,
\13\0\0Ñg]F¶
\ 1\0\0\0\0\0\0\19\0\0\0Doctrine/Common/Lexer.phpK
\e\0\0\99ÈÏLK
\e\0\0NÁã
\ 1¶
\ 1\0\0\0\0\0\0#
\0\0\0Doctrine/Common/EventSubscriber.php
\ 5\a\0\0\99ÈÏL
\ 5\a\0\0iJÛ
\17¶
\ 1\0\0\0\0\0\0\1f\0\0\0Symfony/Component/Yaml/Yaml.php
\9e\v\0\0\99ÈÏL
\9e\v\0\0!
\88¯
\13¶
\ 1\0\0\0\0\0\0!
\0\0\0Symfony/Component/Yaml/Dumper.php
\1c\ 6\0\0\99ÈÏL
\1c\ 6\0\0Ã
\82ßê¶
\ 1\0\0\0\0\0\0*
\0\0\0Symfony/Component/Yaml/ParserException.php
\ f\ 2\0\0\99ÈÏL
\ f\ 2\0\0§³À9¶
\ 1\0\0\0\0\0\0$
\0\0\0Symfony/Component/Yaml/Exception.php
78 \ 2\0\0\ 1WGQ¶
\ 1\0\0\0\0\0\0!
\0\0\0Symfony/Component/Yaml/Inline.php *
\0\0\99ÈÏL *
\0\0:¬
\1fÚ¶
\ 1\0\0\0\0\0\0!
\0\0\0Symfony/Component/Yaml/Parser.php
\90?
\0\0\99ÈÏL
\90?
\0\0í|#ɶ
\ 1\0\0\0\0\0\01
\0\0\0Symfony/Component/Console/Command/ListCommand.php¢
\a\0\0\99ÈÏL¢
\a\0\0ý[¯¤¶
\ 1\0\0\0\0\0\01
\0\0\0Symfony/Component/Console/Command/HelpCommand.phpi
\b\0\0\99ÈÏLi
\b\0\0LÇUí¶
\ 1\0\0\0\0\0\0-
\0\0\0Symfony/Component/Console/Command/Command.phpR8
\0\0\99ÈÏLR8
\0\0\9a¾Dj¶
\ 1\0\0\0\0\0\02
\0\0\0Symfony/Component/Console/Output/ConsoleOutput.phpi
\ 4\0\0\99ÈÏLi
\ 4\0\0Üw*ë¶
\ 1\0\0\0\0\0\04
\0\0\0Symfony/Component/Console/Output/OutputInterface.php¶
\ 4\0\0\99ÈÏL¶
\ 4\0\0ïÛw
\r¶
\ 1\0\0\0\0\0\01
\0\0\0Symfony/Component/Console/Output/StreamOutput.php
\ 3\f\0\0\99ÈÏL
\ 3\f\0\0¿
\9dÐJ¶
\ 1\0\0\0\0\0\0+
\0\0\0Symfony/Component/Console/Output/Output.phpí
\1a\0\0\99ÈÏLí
\1a\0\0Èvs
\r¶
\ 1\0\0\0\0\0\0/
\0\0\0Symfony/Component/Console/Output/NullOutput.phpÕ
\ 2\0\0\99ÈÏLÕ
\ 2\0\0æ1Éê¶
\ 1\0\0\0\0\0\0#
\0\0\0Symfony/Component/Console/Shell.php!
\ f\0\0\99ÈÏL!
\ f\0\0É
\96\ e\9e¶
\ 1\0\0\0\0\0\04
\0\0\0Symfony/Component/Console/Helper/FormatterHelper.php
\ 1 \0\0\99ÈÏL
\ 1 \0\0\10g ø¶
\ 1\0\0\0\0\0\0.
\0\0\0Symfony/Component/Console/Helper/HelperSet.php
\7f \0\0\99ÈÏL
\7f \0\0\14ïÑǶ
\ 1\0\0\0\0\0\0+
\0\0\0Symfony/Component/Console/Helper/Helper.php¿
\ 3\0\0\99ÈÏL¿
\ 3\0\0³
\10憦
\ 1\0\0\0\0\0\04
\0\0\0Symfony/Component/Console/Helper/HelperInterface.php±
\ 3\0\0\99ÈÏL±
\ 3\0\0×ñf
\r¶
\ 1\0\0\0\0\0\01
\0\0\0Symfony/Component/Console/Helper/DialogHelper.php
\94\f\0\0\99ÈÏL
\94\f\0\03Ü.϶
\ 1\0\0\0\0\0\0)
\0\0\0Symfony/Component/Console/Application.php
\89[
\0\0\99ÈÏL
\89[
\0\0¸Nªâ¶
\ 1\0\0\0\0\0\06
\0\0\0Symfony/Component/Console/Tester/ApplicationTester.phpb
80 \0\0ôé*
\19¶
\ 1\0\0\0\0\0\02
\0\0\0Symfony/Component/Console/Tester/CommandTester.php8
82 \0\0µÕ¥®¶
\ 1\0\0\0\0\0\0)
\0\0\0Symfony/Component/Console/Input/Input.php~
\15\0\0\99ÈÏL~
\15\0\0)ª
\97[¶
\ 1\0\0\0\0\0\0.
\0\0\0Symfony/Component/Console/Input/ArrayInput.php
\v\12\0\0\99ÈÏL
\v\12\0\0¿glt¶
\ 1\0\0\0\0\0\0/
\0\0\0Symfony/Component/Console/Input/InputOption.phpA
\13\0\0\99ÈÏLA
\13\0\0ÁÁÇ6¶
\ 1\0\0\0\0\0\03
\0\0\0Symfony/Component/Console/Input/InputDefinition.phpE<
\0\0\99ÈÏLE<
\0\0\84.
\ fú¶
\ 1\0\0\0\0\0\02
\0\0\0Symfony/Component/Console/Input/InputInterface.php¸
\ 5\0\0\99ÈÏL¸
\ 5\0\0\
\85)-¶
\ 1\0\0\0\0\0\0-
\0\0\0Symfony/Component/Console/Input/ArgvInput.php
\89\1d\0\0\99ÈÏL
\89\1d\0\0¥
\eM°¶
\ 1\0\0\0\0\0\0/
\0\0\0Symfony/Component/Console/Input/StringInput.phpÍ
\0\0\99ÈÏLÍ
\0\0g¸kd¶
\ 1\0\0\0\0\0\01
\0\0\0Symfony/Component/Console/Input/InputArgument.phpË
\f\0\0\99ÈÏLË
\f\0\0]×TP¶
\ 1\0\0\0\0\0\0<?php
86 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
87 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
88 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
89 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
90 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
91 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
92 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
93 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
94 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
95 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
96 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
98 * This software consists of voluntary contributions made by many individuals
99 * and is licensed under the LGPL. For more information, see
100 * <http://www.doctrine-project.org>.
103 namespace Doctrine\DBAL\Migrations;
106 * Exception to be thrown in the down() methods of migrations that signifies it
107 * is an irreversible migration and stops execution.
109 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
110 * @link www.doctrine-project.org
112 * @version $Revision$
113 * @author Jonathan H. Wage <jonwage@gmail.com>
115 class IrreversibleMigrationException extends \Exception
119 namespace Doctrine\DBAL\Migrations;
121 class AbortMigrationException extends MigrationException
126 namespace Doctrine\DBAL\Migrations;
128 class SkipMigrationException extends MigrationException
135 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147 * This software consists of voluntary contributions made by many individuals
148 * and is licensed under the LGPL. For more information, see
149 * <http://www.doctrine-project.org>.
152 namespace Doctrine\DBAL\Migrations;
154 use Doctrine\DBAL\Schema\Schema,
155 Doctrine\DBAL\Migrations\Configuration\Configuration,
156 Doctrine\DBAL\Migrations\Version;
159 * Abstract class for individual migrations to extend from.
161 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
162 * @link www.doctrine-project.org
164 * @version $Revision$
165 * @author Jonathan H. Wage <jonwage@gmail.com>
167 abstract class AbstractMigration
169 /** The Migrations Configuration instance for this migration */
170 protected $_configuration;
172 /** The OutputWriter object instance used for outputting information */
173 protected $_outputWriter;
175 /** The Doctrine\DBAL\Connection instance we are migrating */
176 protected $_connection;
178 /** Reference to the SchemaManager instance referened by $_connection */
181 /** Reference to the DatabasePlatform instance referenced by $_conection */
182 protected $_platform;
184 /** Reference to the Version instance representing this migration */
187 public function __construct(Version $version)
189 $this->_configuration = $version->getConfiguration();
190 $this->_outputWriter = $this->_configuration->getOutputWriter();
191 $this->_connection = $this->_configuration->getConnection();
192 $this->_sm = $this->_connection->getSchemaManager();
193 $this->_platform = $this->_connection->getDatabasePlatform();
194 $this->_version = $version;
197 abstract public function up(Schema $schema);
198 abstract public function down(Schema $schema);
200 protected function _addSql($sql)
202 return $this->_version->addSql($sql);
205 protected function _write($message)
207 $this->_outputWriter->write($message);
210 protected function _throwIrreversibleMigrationException($message = null)
212 if ($message === null) {
213 $message = 'This migration is irreversible and cannot be reverted.';
215 throw new IrreversibleMigrationException($message);
219 * Print a warning message if the condition evalutes to TRUE.
221 * @param bool $condition
222 * @param string $message
224 public function warnIf($condition, $message = '')
226 $message = (strlen($message)) ? $message : 'Unknown Reason';
228 if ($condition === true) {
229 $this->_outputWriter->write(' <warning>Warning during ' . $this->_version->getExecutionState() . ': ' . $message . '</warning>');
234 * Abort the migration if the condition evalutes to TRUE.
236 * @param bool $condition
237 * @param string $message
239 public function abortIf($condition, $message = '')
241 $message = (strlen($message)) ? $message : 'Unknown Reason';
243 if ($condition === true) {
244 throw new AbortMigrationException($message);
249 * Skip this migration (but not the next ones) if condition evalutes to TRUE.
251 * @param bool $condition
252 * @param string $message
254 public function skipIf($condition, $message = '')
256 $message = (strlen($message)) ? $message : 'Unknown Reason';
258 if ($condition === true) {
259 throw new SkipMigrationException($message);
263 public function preUp(Schema $schema)
267 public function postUp(Schema $schema)
271 public function preDown(Schema $schema)
275 public function postDown(Schema $schema)
282 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
283 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
284 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
285 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
286 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
287 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
288 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
289 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
290 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
291 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
292 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
294 * This software consists of voluntary contributions made by many individuals
295 * and is licensed under the LGPL. For more information, see
296 * <http://www.doctrine-project.org>.
299 namespace Doctrine\DBAL\Migrations;
302 * Class for Migrations specific exceptions
304 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
305 * @link www.doctrine-project.org
307 * @version $Revision$
308 * @author Jonathan H. Wage <jonwage@gmail.com>
310 class MigrationException extends \Exception
312 public static function migrationsNamespaceRequired()
314 return new self('Migrations namespace must be configured in order to use Doctrine migrations.', 2);
317 public static function migrationsDirectoryRequired()
319 return new self('Migrations directory must be configured in order to use Doctrine migrations.', 3);
322 public static function noMigrationsToExecute()
324 return new self('Could not find any migrations to execute.', 4);
327 public static function unknownMigrationVersion($version)
329 return new self(sprintf('Could not find migration version %s', $version), 5);
332 public static function alreadyAtVersion($version)
334 return new self(sprintf('Database is already at version %s', $version), 6);
337 public static function duplicateMigrationVersion($version, $class)
339 return new self(sprintf('Migration version %s already registered with class %s', $version, $class), 7);
342 public static function configurationFileAlreadyLoaded()
344 return new self(sprintf('Migrations configuration file already loaded'), 8);
351 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
352 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
353 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
354 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
355 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
356 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
357 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
358 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
359 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
360 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
361 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
363 * This software consists of voluntary contributions made by many individuals
364 * and is licensed under the LGPL. For more information, see
365 * <http://www.doctrine-project.org>.
368 namespace Doctrine\DBAL\Migrations;
370 use Doctrine\DBAL\Migrations\Configuration\Configuration,
371 Doctrine\DBAL\Schema\Schema;
374 * Class for running migrations to the current version or a manually specified version.
376 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
377 * @link www.doctrine-project.org
379 * @version $Revision$
380 * @author Jonathan H. Wage <jonwage@gmail.com>
384 /** The Doctrine\DBAL\Connection instance we are migrating */
385 private $_connection;
387 /** The OutputWriter object instance used for outputting information */
388 private $_outputWriter;
391 * Construct a Migration instance
393 * @param Configuration $configuration A migration Configuration instance
395 public function __construct(Configuration $configuration)
397 $this->_configuration = $configuration;
398 $this->_outputWriter = $configuration->getOutputWriter();
402 * Get the array of versions and SQL queries that would be executed for
403 * each version but do not execute anything.
405 * @param string $to The version to migrate to.
406 * @return array $sql The array of SQL queries.
408 public function getSql($to = null)
410 return $this->migrate($to, true);
414 * Write a migration SQL file to the given path
416 * @param string $path The path to write the migration SQL file.
417 * @param string $to The version to migrate to.
418 * @return bool $written
420 public function writeSqlFile($path, $to = null)
422 $sql = $this->getSql($to);
424 $from = $this->_configuration->getCurrentVersion();
426 $to = $this->_configuration->getLatestVersion();
429 $string = sprintf("# Doctrine Migration File Generated on %s\n", date('Y-m-d H:m:s'));
430 $string .= sprintf("# Migrating from %s to %s\n", $from, $to);
432 foreach ($sql as $version => $queries) {
433 $string .= "\n# Version " . $version . "\n";
434 foreach ($queries as $query) {
435 $string .= $query . ";\n";
439 $path = realpath($path);
440 $path = $path . '/doctrine_migration_' . date('YmdHis') . '.sql';
443 $this->_outputWriter->write("\n".sprintf('Writing migration file to "<info>%s</info>"', $path));
445 return file_put_contents($path, $string);
449 * Run a migration to the current version or the given target version.
451 * @param string $to The version to migrate to.
452 * @param string $dryRun Whether or not to make this a dry run and not execute anything.
453 * @return array $sql The array of migration sql statements
454 * @throws MigrationException
456 public function migrate($to = null, $dryRun = false)
459 $to = $this->_configuration->getLatestVersion();
462 $from = $this->_configuration->getCurrentVersion();
463 $from = (string) $from;
466 $migrations = $this->_configuration->getMigrations();
467 if ( ! isset($migrations[$to]) && $to > 0) {
468 throw MigrationException::unknownMigrationVersion($to);
472 throw MigrationException::alreadyAtVersion($to);
475 $direction = $from > $to ? 'down' : 'up';
476 $migrations = $this->_configuration->getMigrationsToExecute($direction, $to);
478 if ($dryRun === false) {
479 $this->_outputWriter->write(sprintf('Migrating <info>%s</info> to <comment>%s</comment> from <comment>%s</comment>', $direction, $to, $from));
481 $this->_outputWriter->write(sprintf('Executing dry run of migration <info>%s</info> to <comment>%s</comment> from <comment>%s</comment>', $direction, $to, $from));
484 if (empty($migrations)) {
485 throw MigrationException::noMigrationsToExecute();
490 foreach ($migrations as $version) {
491 $versionSql = $version->execute($direction, $dryRun);
492 $sql[$version->getVersion()] = $versionSql;
493 $time += $version->getTime();
496 $this->_outputWriter->write("\n <comment>------------------------</comment>\n");
497 $this->_outputWriter->write(sprintf(" <info>++</info> finished in %s", $time));
498 $this->_outputWriter->write(sprintf(" <info>++</info> %s migrations executed", count($migrations)));
499 $this->_outputWriter->write(sprintf(" <info>++</info> %s sql queries", count($sql, true) - count($sql)));
508 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
509 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
510 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
511 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
512 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
513 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
514 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
515 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
516 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
517 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
518 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
520 * This software consists of voluntary contributions made by many individuals
521 * and is licensed under the LGPL. For more information, see
522 * <http://www.doctrine-project.org>.
525 namespace Doctrine\DBAL\Migrations\Configuration;
527 use Doctrine\DBAL\Connection,
528 Doctrine\DBAL\Migrations\MigrationException,
529 Doctrine\DBAL\Migrations\Version,
530 Doctrine\DBAL\Migrations\OutputWriter,
531 Doctrine\DBAL\Schema\Table,
532 Doctrine\DBAL\Schema\Column,
533 Doctrine\DBAL\Types\Type;
536 * Default Migration Configurtion object used for configuring an instance of
537 * the Migration class. Set the connection, version table name, register migration
538 * classes/versions, etc.
540 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
541 * @link www.doctrine-project.org
543 * @version $Revision$
544 * @author Jonathan H. Wage <jonwage@gmail.com>
548 /** Name of this set of migrations */
551 /** Flag for whether or not the migration table has been created */
552 private $_migrationTableCreated = false;
554 /** Connection instance to use for migrations */
555 private $_connection;
557 /** OutputWriter instance for writing output during migrations */
558 private $_outputWriter;
560 /** The migration table name to track versions in */
561 private $_migrationsTableName = 'doctrine_migration_versions';
563 /** The path to a directory where new migration classes will be written */
564 private $_migrationsDirectory;
566 /** Namespace the migration classes live in */
567 private $_migrationsNamespace;
569 /** Array of the registered migrations */
570 private $_migrations = array();
573 * Construct a migration configuration object.
575 * @param Connection $connection A Connection instance
576 * @param OutputWriter $outputWriter A OutputWriter instance
578 public function __construct(Connection $connection, OutputWriter $outputWriter = null)
580 $this->_connection = $connection;
581 if ($outputWriter === null) {
582 $outputWriter = new OutputWriter();
584 $this->_outputWriter = $outputWriter;
588 * Validation that this instance has all the required properties configured
591 * @throws MigrationException
593 public function validate()
595 if ( ! $this->_migrationsNamespace) {
596 throw MigrationException::migrationsNamespaceRequired();
598 if ( ! $this->_migrationsDirectory) {
599 throw MigrationException::migrationsDirectoryRequired();
604 * Set the name of this set of migrations
606 * @param string $name The name of this set of migrations
608 public function setName($name)
610 $this->_name = $name;
614 * Returns the name of this set of migrations
616 * @return string $name The name of this set of migrations
618 public function getName()
624 * Returns the OutputWriter instance
626 * @return OutputWriter $outputWriter The OutputWriter instance
628 public function getOutputWriter()
630 return $this->_outputWriter;
634 * Returns a timestamp version as a formatted date
636 * @param string $version
637 * @return string $formattedVersion The formatted version
639 public function formatVersion($version)
641 return sprintf('%s-%s-%s %s:%s:%s',
642 substr($version, 0, 4),
643 substr($version, 4, 2),
644 substr($version, 6, 2),
645 substr($version, 8, 2),
646 substr($version, 10, 2),
647 substr($version, 12, 2)
652 * Returns the Connection instance
654 * @return Connection $connection The Connection instance
656 public function getConnection()
658 return $this->_connection;
662 * Set the migration table name
664 * @param string $tableName The migration table name
666 public function setMigrationsTableName($tableName)
668 $this->_migrationsTableName = $tableName;
672 * Returns the migration table name
674 * @return string $migrationsTableName The migration table name
676 public function getMigrationsTableName()
678 return $this->_migrationsTableName;
682 * Set the new migrations directory where new migration classes are generated
684 * @param string $migrationsDirectory The new migrations directory
686 public function setMigrationsDirectory($migrationsDirectory)
688 $this->_migrationsDirectory = $migrationsDirectory;
692 * Returns the new migrations directory where new migration classes are generated
694 * @return string $migrationsDirectory The new migrations directory
696 public function getMigrationsDirectory()
698 return $this->_migrationsDirectory;
702 * Set the migrations namespace
704 * @param string $migrationsNamespace The migrations namespace
706 public function setMigrationsNamespace($migrationsNamespace)
708 $this->_migrationsNamespace = $migrationsNamespace;
712 * Returns the migrations namespace
714 * @return string $migrationsNamespace The migrations namespace
716 public function getMigrationsNamespace()
718 return $this->_migrationsNamespace;
722 * Register migrations from a given directory. Recursively finds all files
723 * with the pattern VersionYYYYMMDDHHMMSS.php as the filename and registers
724 * them as migrations.
726 * @param string $path The root directory to where some migration classes live.
727 * @return $migrations The array of migrations registered.
729 public function registerMigrationsFromDirectory($path)
731 $path = realpath($path);
732 $path = rtrim($path, '/');
733 $files = glob($path . '/Version*.php');
735 foreach ($files as $file) {
737 $info = pathinfo($file);
738 $version = substr($info['filename'], 7);
739 $class = $this->_migrationsNamespace . '\\' . $info['filename'];
740 $versions[] = $this->registerMigration($version, $class);
746 * Register a single migration version to be executed by a AbstractMigration
749 * @param string $version The version of the migration in the format YYYYMMDDHHMMSS.
750 * @param string $class The migration class to execute for the version.
752 public function registerMigration($version, $class)
754 $version = (string) $version;
755 $class = (string) $class;
756 if (isset($this->_migrations[$version])) {
757 throw MigrationException::duplicateMigrationVersion($version, get_class($this->_migrations[$version]));
759 $version = new Version($this, $version, $class);
760 $this->_migrations[$version->getVersion()] = $version;
761 ksort($this->_migrations);
766 * Register an array of migrations. Each key of the array is the version and
767 * the value is the migration class name.
770 * @param array $migrations
773 public function registerMigrations(array $migrations)
776 foreach ($migrations as $version => $class) {
777 $versions[] = $this->registerMigration($version, $class);
783 * Get the array of registered migration versions.
785 * @return array $migrations
787 public function getMigrations()
789 return $this->_migrations;
793 * Returns the Version instance for a given version in the format YYYYMMDDHHMMSS.
795 * @param string $version The version string in the format YYYYMMDDHHMMSS.
796 * @return Version $version
797 * @throws MigrationException $exception Throws exception if migration version does not exist.
799 public function getVersion($version)
801 if ( ! isset($this->_migrations[$version])) {
802 MigrationException::unknownMigrationVersion($version);
804 return $this->_migrations[$version];
808 * Check if a version exists.
810 * @param string $version
811 * @return bool $exists
813 public function hasVersion($version)
815 return isset($this->_migrations[$version]) ? true : false;
819 * Check if a version has been migrated or not yet
821 * @param Version $version
822 * @return bool $migrated
824 public function hasVersionMigrated(Version $version)
826 $this->createMigrationTable();
828 $version = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationsTableName . " WHERE version = '" . $version->getVersion() . "'");
829 return $version !== false ? true : false;
833 * Returns the current migrated version from the versions table.
835 * @return bool $currentVersion
837 public function getCurrentVersion()
839 $this->createMigrationTable();
841 $result = $this->_connection->fetchColumn("SELECT version FROM " . $this->_migrationsTableName . " ORDER BY version DESC LIMIT 1");
842 return $result !== false ? (string) $result : '0';
846 * Returns the total number of executed migration versions
848 * @return integer $count
850 public function getNumberOfExecutedMigrations()
852 $this->createMigrationTable();
854 $result = $this->_connection->fetchColumn("SELECT COUNT(version) FROM " . $this->_migrationsTableName);
855 return $result !== false ? $result : 0;
859 * Returns the total number of available migration versions
861 * @return integer $count
863 public function getNumberOfAvailableMigrations()
865 return count($this->_migrations);
869 * Returns the latest available migration version.
871 * @return string $version The version string in the format YYYYMMDDHHMMSS.
873 public function getLatestVersion()
875 $versions = array_keys($this->_migrations);
876 $latest = end($versions);
877 return $latest !== false ? (string) $latest : '0';
881 * Create the migration table to track migrations with.
883 * @return bool $created Whether or not the table was created.
885 public function createMigrationTable()
889 if ($this->_migrationTableCreated) {
893 $schema = $this->_connection->getSchemaManager()->createSchema();
894 if ( ! $schema->hasTable($this->_migrationsTableName)) {
896 'version' => new Column('version', Type::getType('string'), array('length' => 14)),
898 $table = new Table($this->_migrationsTableName, $columns);
899 $table->setPrimaryKey(array('version'));
900 $this->_connection->getSchemaManager()->createTable($table);
902 $this->_migrationTableCreated = true;
910 * Returns the array of migrations to executed based on the given direction
911 * and target version number.
913 * @param string $direction The direction we are migrating.
914 * @param string $to The version to migrate to.
915 * @return array $migrations The array of migrations we can execute.
917 public function getMigrationsToExecute($direction, $to)
919 if ($direction === 'down') {
920 $allVersions = array_reverse(array_keys($this->_migrations));
921 $classes = array_reverse(array_values($this->_migrations));
922 $allVersions = array_combine($allVersions, $classes);
924 $allVersions = $this->_migrations;
927 foreach ($allVersions as $version) {
928 if ($this->_shouldExecuteMigration($direction, $version, $to)) {
929 $versions[$version->getVersion()] = $version;
936 * Check if we should execute a migration for a given direction and target
939 * @param string $direction The direction we are migrating.
940 * @param Version $version The Version instance to check.
941 * @param string $to The version we are migrating to.
944 private function _shouldExecuteMigration($direction, Version $version, $to)
946 if ($direction === 'down') {
947 if ( ! $this->hasVersionMigrated($version)) {
950 return $version->getVersion() > $to ? true : false;
951 } else if ($direction === 'up') {
952 if ($this->hasVersionMigrated($version)) {
955 return $version->getVersion() <= $to ? true : false;
962 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
963 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
964 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
965 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
966 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
967 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
968 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
969 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
970 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
971 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
972 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
974 * This software consists of voluntary contributions made by many individuals
975 * and is licensed under the LGPL. For more information, see
976 * <http://www.doctrine-project.org>.
979 namespace Doctrine\DBAL\Migrations\Configuration;
982 * Load migration configuration information from a XML configuration file.
984 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
985 * @link www.doctrine-project.org
987 * @version $Revision$
988 * @author Jonathan H. Wage <jonwage@gmail.com>
990 class XmlConfiguration extends AbstractFileConfiguration
995 protected function _load($file)
997 $xml = simplexml_load_file($file);
998 if (isset($xml->name)) {
999 $this->setName((string) $xml->name);
1001 if (isset($xml->table['name'])) {
1002 $this->setMigrationsTableName((string) $xml->table['name']);
1004 if (isset($xml->{'migrations-namespace'})) {
1005 $this->setMigrationsNamespace((string) $xml->{'migrations-namespace'});
1007 if (isset($xml->{'migrations-directory'})) {
1008 $migrationsDirectory = $this->_getDirectoryRelativeToFile($file, (string) $xml->{'migrations-directory'});
1009 $this->setMigrationsDirectory($migrationsDirectory);
1010 $this->registerMigrationsFromDirectory($migrationsDirectory);
1012 if (isset($xml->migrations->migration)) {
1013 foreach ($xml->migrations->migration as $migration) {
1014 $this->registerMigration((string) $migration['version'], (string) $migration['class']);
1022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1026 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1034 * This software consists of voluntary contributions made by many individuals
1035 * and is licensed under the LGPL. For more information, see
1036 * <http://www.doctrine-project.org>.
1039 namespace Doctrine\DBAL\Migrations\Configuration;
1041 use Symfony\Component\Yaml\Yaml;
1044 * Load migration configuration information from a YAML configuration file.
1046 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1047 * @link www.doctrine-project.org
1049 * @version $Revision$
1050 * @author Jonathan H. Wage <jonwage@gmail.com>
1052 class YamlConfiguration extends AbstractFileConfiguration
1057 protected function _load($file)
1059 $array = Yaml::load($file);
1061 if (isset($array['name'])) {
1062 $this->setName($array['name']);
1064 if (isset($array['table_name'])) {
1065 $this->setMigrationsTableName($array['table_name']);
1067 if (isset($array['migrations_namespace'])) {
1068 $this->setMigrationsNamespace($array['migrations_namespace']);
1070 if (isset($array['migrations_directory'])) {
1071 $migrationsDirectory = $this->_getDirectoryRelativeToFile($file, $array['migrations_directory']);
1072 $this->setMigrationsDirectory($migrationsDirectory);
1073 $this->registerMigrationsFromDirectory($migrationsDirectory);
1075 if (isset($array['migrations']) && is_array($array['migrations'])) {
1076 foreach ($array['migrations'] as $migration) {
1077 $this->registerMigration($migration['version'], $migration['class']);
1086 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1087 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1088 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1089 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1090 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1091 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1092 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1093 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1094 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1095 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1096 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1098 * This software consists of voluntary contributions made by many individuals
1099 * and is licensed under the LGPL. For more information, see
1100 * <http://www.doctrine-project.org>.
1103 namespace Doctrine\DBAL\Migrations\Configuration;
1105 use Doctrine\DBAL\Migrations\MigrationsException;
1108 * Abstract Migration Configuration class for loading configuration information
1109 * from a configuration file (xml or yml).
1111 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1112 * @link www.doctrine-project.org
1114 * @version $Revision$
1115 * @author Jonathan H. Wage <jonwage@gmail.com>
1117 abstract class AbstractFileConfiguration extends Configuration
1119 /** The configuration file used to load configuration information */
1122 /** Whether or not the configuration file has been loaded yet or not */
1123 private $_loaded = false;
1126 * Load the information from the passed configuration file
1128 * @param string $file The path to the configuration file
1130 * @throws MigrationException $exception Throws exception if configuration file was already loaded
1132 public function load($file)
1134 if ($this->_loaded) {
1135 throw MigrationsException::configurationFileAlreadyLoaded();
1137 if (file_exists($path = getcwd() . '/' . $file)) {
1140 $this->_file = $file;
1141 $this->_load($file);
1142 $this->_loaded = true;
1145 protected function _getDirectoryRelativeToFile($file, $input)
1147 $path = realpath(dirname($file) . '/' . $input);
1148 if ($path !== false) {
1151 $directory = $input;
1156 public function getFile()
1158 return $this->_file;
1162 * Abstract method that each file configuration driver must implement to
1163 * load the given configuration file whether it be xml, yaml, etc. or something
1166 * @param string $file The path to a configuration file.
1168 abstract protected function _load($file);
1173 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1174 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1175 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1176 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1177 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1178 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1179 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1180 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1181 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1182 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1183 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1185 * This software consists of voluntary contributions made by many individuals
1186 * and is licensed under the LGPL. For more information, see
1187 * <http://www.doctrine-project.org>.
1190 namespace Doctrine\DBAL\Migrations;
1193 * Simple class for outputting information from migrations.
1195 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1196 * @link www.doctrine-project.org
1198 * @version $Revision$
1199 * @author Jonathan H. Wage <jonwage@gmail.com>
1205 public function __construct(\Closure $closure = null)
1207 if ($closure === null) {
1208 $closure = function($message) {};
1210 $this->_closure = $closure;
1214 * Write output using the configured closure.
1216 * @param string $message The message to write.
1218 public function write($message)
1220 $closure = $this->_closure;
1227 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1228 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1229 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1230 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1231 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1232 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1233 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1234 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1235 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1236 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1237 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1239 * This software consists of voluntary contributions made by many individuals
1240 * and is licensed under the LGPL. For more information, see
1241 * <http://www.doctrine-project.org>.
1244 namespace Doctrine\DBAL\Migrations;
1246 use Doctrine\DBAL\Migrations\Configuration\Configuration,
1247 Doctrine\DBAL\Schema\Schema;
1250 * Class which wraps a migration version and allows execution of the
1251 * individual migration version up or down method.
1253 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1254 * @link www.doctrine-project.org
1256 * @version $Revision$
1257 * @author Jonathan H. Wage <jonwage@gmail.com>
1261 const STATE_NONE = 0;
1262 const STATE_PRE = 1;
1263 const STATE_EXEC = 2;
1264 const STATE_POST = 3;
1267 * The Migrations Configuration instance for this migration
1269 * @var Configuration
1271 private $_configuration;
1274 * The OutputWriter object instance used for outputting information
1278 private $_outputWriter;
1281 * The version in timestamp format (YYYYMMDDHHMMSS)
1288 * @var AbstractSchemaManager
1293 * @var AbstractPlatform
1298 * The migration instance for this version
1300 * @var AbstractMigration
1302 private $_migration;
1307 private $_connection;
1314 /** The array of collected SQL statements for this version */
1315 private $_sql = array();
1317 /** The time in seconds that this migration version took to execute */
1323 private $_state = self::STATE_NONE;
1325 public function __construct(Configuration $configuration, $version, $class)
1327 $this->_configuration = $configuration;
1328 $this->_outputWriter = $configuration->getOutputWriter();
1329 $this->_version = $version;
1330 $this->_class = $class;
1331 $this->_connection = $configuration->getConnection();
1332 $this->_sm = $this->_connection->getSchemaManager();
1333 $this->_platform = $this->_connection->getDatabasePlatform();
1334 $this->_migration = new $class($this);
1338 * Returns the string version in the format YYYYMMDDHHMMSS
1340 * @return string $version
1342 public function getVersion()
1344 return $this->_version;
1348 * Returns the Migrations Configuration object instance
1350 * @return Configuration $configuration
1352 public function getConfiguration()
1354 return $this->_configuration;
1358 * Check if this version has been migrated or not.
1363 public function isMigrated()
1365 return $this->_configuration->hasVersionMigrated($this);
1368 public function markMigrated()
1370 $this->_configuration->createMigrationTable();
1371 $this->_connection->executeQuery("INSERT INTO " . $this->_configuration->getMigrationsTableName() . " (version) VALUES (?)", array($this->_version));
1374 public function markNotMigrated()
1376 $this->_configuration->createMigrationTable();
1377 $this->_connection->executeQuery("DELETE FROM " . $this->_configuration->getMigrationsTableName() . " WHERE version = '$this->_version'");
1381 * Add some SQL queries to this versions migration
1386 public function addSql($sql)
1388 if (is_array($sql)) {
1389 foreach ($sql as $query) {
1390 $this->_sql[] = $query;
1393 $this->_sql[] = $sql;
1398 * Write a migration SQL file to the given path
1400 * @param string $path The path to write the migration SQL file.
1401 * @param string $direction The direction to execute.
1402 * @return bool $written
1404 public function writeSqlFile($path, $direction = 'up')
1406 $queries = $this->execute($direction, true);
1408 $string = sprintf("# Doctrine Migration File Generated on %s\n", date('Y-m-d H:m:s'));
1410 $string .= "\n# Version " . $this->_version . "\n";
1411 foreach ($queries as $query) {
1412 $string .= $query . ";\n";
1414 if (is_dir($path)) {
1415 $path = realpath($path);
1416 $path = $path . '/doctrine_migration_' . date('YmdHis') . '.sql';
1419 $this->_outputWriter->write("\n".sprintf('Writing migration file to "<info>%s</info>"', $path));
1421 return file_put_contents($path, $string);
1425 * Execute this migration version up or down and and return the SQL.
1427 * @param string $direction The direction to execute the migration.
1428 * @param string $dryRun Whether to not actually execute the migration SQL and just do a dry run.
1429 * @return array $sql
1430 * @throws Exception when migration fails
1432 public function execute($direction, $dryRun = false)
1434 $this->_sql = array();
1436 $this->_connection->beginTransaction();
1439 $start = microtime(true);
1441 $this->_state = self::STATE_PRE;
1442 $fromSchema = $this->_sm->createSchema();
1443 $this->_migration->{'pre' . ucfirst($direction)}($fromSchema);
1445 if ($direction === 'up') {
1446 $this->_outputWriter->write("\n" . sprintf(' <info>++</info> migrating <comment>%s</comment>', $this->_version) . "\n");
1448 $this->_outputWriter->write("\n" . sprintf(' <info>--</info> reverting <comment>%s</comment>', $this->_version) . "\n");
1451 $this->_state = self::STATE_EXEC;
1453 $toSchema = clone $fromSchema;
1454 $this->_migration->$direction($toSchema);
1455 $this->addSql($fromSchema->getMigrateToSql($toSchema, $this->_platform));
1457 if ($dryRun === false) {
1459 $count = count($this->_sql);
1460 foreach ($this->_sql as $query) {
1461 $this->_outputWriter->write(' <comment>-></comment> ' . $query);
1462 $this->_connection->executeQuery($query);
1465 if ($direction === 'up') {
1466 $this->markMigrated();
1468 $this->markNotMigrated();
1471 $this->_outputWriter->write(sprintf('<error>Migration %s was executed but did not result in any SQL statements.</error>', $this->_version));
1474 foreach ($this->_sql as $query) {
1475 $this->_outputWriter->write(' <comment>-></comment> ' . $query);
1479 $this->_state = self::STATE_POST;
1480 $this->_migration->{'post' . ucfirst($direction)}($toSchema);
1482 $end = microtime(true);
1483 $this->_time = round($end - $start, 2);
1484 if ($direction === 'up') {
1485 $this->_outputWriter->write(sprintf("\n <info>++</info> migrated (%ss)", $this->_time));
1487 $this->_outputWriter->write(sprintf("\n <info>--</info> reverted (%ss)", $this->_time));
1490 $this->_connection->commit();
1493 } catch(SkipMigrationException $e) {
1494 $this->_connection->rollback();
1496 // now mark it as migrated
1497 if ($direction === 'up') {
1498 $this->markMigrated();
1500 $this->markNotMigrated();
1503 $this->_outputWriter->write(sprintf("\n <info>SS</info> skipped (Reason: %s)", $e->getMessage()));
1504 } catch (\Exception $e) {
1506 $this->_outputWriter->write(sprintf(
1507 '<error>Migration %s failed during %s. Error %s</error>',
1508 $this->_version, $this->getExecutionState(), $e->getMessage()
1511 $this->_connection->rollback();
1513 $this->_state = self::STATE_NONE;
1516 $this->_state = self::STATE_NONE;
1519 public function getExecutionState()
1521 switch($this->_state) {
1522 case self::STATE_PRE:
1523 return 'Pre-Checks';
1524 case self::STATE_POST:
1525 return 'Post-Checks';
1526 case self::STATE_EXEC:
1534 * Returns the time this migration version took to execute
1536 * @return integer $time The time this migration version took to execute
1538 public function getTime()
1540 return $this->_time;
1543 public function __toString()
1545 return $this->_version;
1550 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1551 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1552 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1553 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1554 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1555 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1556 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1557 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1558 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1559 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1560 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1562 * This software consists of voluntary contributions made by many individuals
1563 * and is licensed under the LGPL. For more information, see
1564 * <http://www.doctrine-project.org>.
1568 namespace Doctrine\DBAL\Migrations;
1570 class MigrationsVersion
1572 const VERSION = '2.0.0-DEV';
1577 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1578 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1579 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1580 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1581 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1582 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1583 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1584 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1585 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1586 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1587 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1589 * This software consists of voluntary contributions made by many individuals
1590 * and is licensed under the LGPL. For more information, see
1591 * <http://www.doctrine-project.org>.
1594 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
1596 use Symfony\Component\Console\Input\InputInterface,
1597 Symfony\Component\Console\Output\OutputInterface,
1598 Symfony\Component\Console\Input\InputArgument,
1599 Symfony\Component\Console\Input\InputOption,
1600 Doctrine\ORM\Tools\SchemaTool,
1601 Doctrine\DBAL\Migrations\Configuration\Configuration;
1604 * Command for generate migration classes by comparing your current database schema
1605 * to your mapping information.
1607 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1608 * @link www.doctrine-project.org
1610 * @version $Revision$
1611 * @author Jonathan Wage <jonwage@gmail.com>
1613 class DiffCommand extends GenerateCommand
1615 protected function configure()
1617 parent::configure();
1620 ->setName('migrations:diff')
1621 ->setDescription('Generate a migration by comparing your current database to your mapping information.')
1623 The <info>%command.name%</info> command generates a migration by comparing your current database to your mapping information:
1625 <info>%command.full_name%</info>
1627 You can optionally specify a <comment>--editor-cmd</comment> option to open the generated file in your favorite editor:
1629 <info>%command.full_name% --editor-cmd=mate</info>
1635 public function execute(InputInterface $input, OutputInterface $output)
1637 $configuration = $this->_getMigrationConfiguration($input, $output);
1639 $em = $this->getHelper('em')->getEntityManager();
1640 $conn = $em->getConnection();
1641 $platform = $conn->getDatabasePlatform();
1642 $metadata = $em->getMetadataFactory()->getAllMetadata();
1644 if (empty($metadata)) {
1645 $output->writeln('No mapping information to process.', 'ERROR');
1649 $tool = new SchemaTool($em);
1651 $fromSchema = $conn->getSchemaManager()->createSchema();
1652 $toSchema = $tool->getSchemaFromMetadata($metadata);
1653 $up = $this->_buildCodeFromSql($configuration, $fromSchema->getMigrateToSql($toSchema, $platform));
1654 $down = $this->_buildCodeFromSql($configuration, $fromSchema->getMigrateFromSql($toSchema, $platform));
1656 if ( ! $up && ! $down) {
1657 $output->writeln('No changes detected in your mapping information.', 'ERROR');
1661 $version = date('YmdHis');
1662 $path = $this->_generateMigration($configuration, $input, $version, $up, $down);
1664 $output->writeln(sprintf('Generated new migration class to "<info>%s</info>" from schema differences.', $path));
1667 private function _buildCodeFromSql(Configuration $configuration, array $sql)
1670 foreach ($sql as $query) {
1671 if (strpos($query, $configuration->getMigrationsTableName()) !== false) {
1674 $code[] = "\$this->_addSql('" . $query . "');";
1676 return implode("\n", $code);
1683 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1684 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1685 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1686 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1687 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1688 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1689 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1690 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1691 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1692 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1693 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1695 * This software consists of voluntary contributions made by many individuals
1696 * and is licensed under the LGPL. For more information, see
1697 * <http://www.doctrine-project.org>.
1700 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
1702 use Symfony\Component\Console\Command\Command,
1703 Symfony\Component\Console\Input\InputInterface,
1704 Symfony\Component\Console\Output\OutputInterface,
1705 Symfony\Component\Console\Input\InputOption,
1706 Doctrine\DBAL\Migrations\Migration,
1707 Doctrine\DBAL\Migrations\MigrationException,
1708 Doctrine\DBAL\Migrations\OutputWriter,
1709 Doctrine\DBAL\Migrations\Configuration\Configuration,
1710 Doctrine\DBAL\Migrations\Configuration\YamlConfiguration,
1711 Doctrine\DBAL\Migrations\Configuration\XmlConfiguration;
1714 * CLI Command for adding and deleting migration versions from the version table.
1716 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1717 * @link www.doctrine-project.org
1719 * @version $Revision$
1720 * @author Jonathan Wage <jonwage@gmail.com>
1722 abstract class AbstractCommand extends Command
1724 protected $_configuration;
1726 protected function configure()
1728 $this->addOption('configuration', null, InputOption::PARAMETER_OPTIONAL, 'The path to a migrations configuration file.');
1729 $this->addOption('db-configuration', null, InputOption::PARAMETER_OPTIONAL, 'The path to a database connection configuration file.');
1732 protected function _outputHeader(Configuration $configuration, OutputInterface $output)
1734 $name = $configuration->getName();
1735 $name = $name ? $name : 'Doctrine Database Migrations';
1736 $name = str_repeat(' ', 20) . $name . str_repeat(' ', 20);
1737 $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>');
1738 $output->writeln('<question>' . $name . '</question>');
1739 $output->writeln('<question>' . str_repeat(' ', strlen($name)) . '</question>');
1740 $output->writeln('');
1744 * @param InputInterface $input
1745 * @param OutputInterface $output
1746 * @return Configuration
1748 protected function _getMigrationConfiguration(InputInterface $input, OutputInterface $output)
1750 if ( ! $this->_configuration) {
1751 $outputWriter = new OutputWriter(function($message) use ($output) {
1752 return $output->writeln($message);
1755 if ($this->application->getHelperSet()->has('db')) {
1756 $conn = $this->getHelper('db')->getConnection();
1757 } else if($input->getOption('db-configuration')) {
1758 if (!file_exists($input->getOption('db-configuration'))) {
1759 throw new \InvalidArgumentException("The specified connection file is a valid file.");
1762 $params = include($input->getOption('db-configuration'));
1763 if (!is_array($params)) {
1764 throw new \InvalidArgumentException('The connection file has to return an array with database configuration parameters.');
1766 $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
1767 } else if (file_exists('migrations-db.php')) {
1768 $params = include("migrations-db.php");
1769 if (!is_array($params)) {
1770 throw new \InvalidArgumentException('The connection file has to return an array with database configuration parameters.');
1772 $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
1774 throw new \InvalidArgumentException('You have to specify a --db-configuration file or pass a Database Connection as a dependency to the Migrations.');
1777 if ($input->getOption('configuration')) {
1778 $info = pathinfo($input->getOption('configuration'));
1779 $class = $info['extension'] === 'xml' ? 'Doctrine\DBAL\Migrations\Configuration\XmlConfiguration' : 'Doctrine\DBAL\Migrations\Configuration\YamlConfiguration';
1780 $configuration = new $class($conn, $outputWriter);
1781 $configuration->load($input->getOption('configuration'));
1782 } else if (file_exists('migrations.xml')) {
1783 $configuration = new XmlConfiguration($conn, $outputWriter);
1784 $configuration->load('migrations.xml');
1785 } else if (file_exists('migrations.yml')) {
1786 $configuration = new YamlConfiguration($conn, $outputWriter);
1787 $configuration->load('migrations.yml');
1789 $configuration = new Configuration($conn, $outputWriter);
1791 $this->_configuration = $configuration;
1793 return $this->_configuration;
1800 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1801 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1802 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1803 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1804 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1805 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1806 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1807 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1808 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1809 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1810 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1812 * This software consists of voluntary contributions made by many individuals
1813 * and is licensed under the LGPL. For more information, see
1814 * <http://www.doctrine-project.org>.
1817 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
1819 use Symfony\Component\Console\Input\InputInterface,
1820 Symfony\Component\Console\Output\OutputInterface,
1821 Symfony\Component\Console\Input\InputArgument,
1822 Symfony\Component\Console\Input\InputOption,
1823 Doctrine\DBAL\Migrations\MigrationException,
1824 Doctrine\DBAL\Migrations\Configuration\Configuration;
1827 * Command for generating new blank migration classes
1829 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1830 * @link www.doctrine-project.org
1832 * @version $Revision$
1833 * @author Jonathan Wage <jonwage@gmail.com>
1835 class GenerateCommand extends AbstractCommand
1837 private static $_template =
1840 namespace <namespace>;
1842 use Doctrine\DBAL\Migrations\AbstractMigration,
1843 Doctrine\DBAL\Schema\Schema;
1845 class Version<version> extends AbstractMigration
1847 public function up(Schema $schema)
1852 public function down(Schema $schema)
1858 protected function configure()
1861 ->setName('migrations:generate')
1862 ->setDescription('Generate a blank migration class.')
1863 ->addOption('editor-cmd', null, InputOption::PARAMETER_OPTIONAL, 'Open file with this command upon creation.')
1865 The <info>%command.name%</info> command generates a blank migration class:
1867 <info>%command.full_name%</info>
1869 You can optionally specify a <comment>--editor-cmd</comment> option to open the generated file in your favorite editor:
1871 <info>%command.full_name% --editor-cmd=mate</info>
1875 parent::configure();
1878 public function execute(InputInterface $input, OutputInterface $output)
1880 $configuration = $this->_getMigrationConfiguration($input, $output);
1882 $version = date('YmdHis');
1883 $path = $this->_generateMigration($configuration, $input, $version);
1885 $output->writeln(sprintf('Generated new migration class to "<info>%s</info>"', $path));
1888 protected function _generateMigration(Configuration $configuration, InputInterface $input, $version, $up = null, $down = null)
1890 $placeHolders = array(
1896 $replacements = array(
1897 $configuration->getMigrationsNamespace(),
1899 $up ? " " . implode("\n ", explode("\n", $up)) : null,
1900 $down ? " " . implode("\n ", explode("\n", $down)) : null
1902 $code = str_replace($placeHolders, $replacements, self::$_template);
1903 $dir = $configuration->getMigrationsDirectory();
1904 $dir = $dir ? $dir : getcwd();
1905 $dir = rtrim($dir, '/');
1906 $path = $dir . '/Version' . $version . '.php';
1908 file_put_contents($path, $code);
1910 if ($editorCmd = $input->getOption('editor-cmd'))
1912 shell_exec($editorCmd . ' ' . escapeshellarg($path));
1922 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1923 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1924 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1925 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1926 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1927 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1928 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1929 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1930 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1931 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1932 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1934 * This software consists of voluntary contributions made by many individuals
1935 * and is licensed under the LGPL. For more information, see
1936 * <http://www.doctrine-project.org>.
1939 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
1941 use Symfony\Component\Console\Input\InputInterface,
1942 Symfony\Component\Console\Output\OutputInterface,
1943 Symfony\Component\Console\Input\InputArgument,
1944 Symfony\Component\Console\Input\InputOption,
1945 Doctrine\DBAL\Migrations\Migration,
1946 Doctrine\DBAL\Migrations\MigrationException,
1947 Doctrine\DBAL\Migrations\Configuration\Configuration,
1948 Doctrine\DBAL\Migrations\Configuration\YamlConfiguration,
1949 Doctrine\DBAL\Migrations\Configuration\XmlConfiguration;
1952 * Command for manually adding and deleting migration versions from the version table.
1954 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
1955 * @link www.doctrine-project.org
1957 * @version $Revision$
1958 * @author Jonathan Wage <jonwage@gmail.com>
1960 class VersionCommand extends AbstractCommand
1962 protected function configure()
1965 ->setName('migrations:version')
1966 ->setDescription('Manually add and delete migration versions from the version table.')
1967 ->addArgument('version', InputArgument::REQUIRED, 'The version to add or delete.', null)
1968 ->addOption('add', null, InputOption::PARAMETER_NONE, 'Add the specified version.')
1969 ->addOption('delete', null, InputOption::PARAMETER_NONE, 'Delete the specified version.')
1971 The <info>%command.name%</info> command allows you to manually add and delete migration versions from the version table:
1973 <info>%command.full_name% YYYYMMDDHHMMSS --add</info>
1975 If you want to delete a version you can use the <comment>--delete</comment> option:
1977 <info>%command.full_name% YYYYMMDDHHMMSS --delete</info>
1981 parent::configure();
1984 public function execute(InputInterface $input, OutputInterface $output)
1986 $configuration = $this->_getMigrationConfiguration($input, $output);
1987 $migration = new Migration($configuration);
1989 if ($input->getOption('add') === false && $input->getOption('delete') === false) {
1990 throw new \InvalidArgumentException('You must specify whether you want to --add or --delete the specified version.');
1993 $version = $input->getArgument('version');
1994 $markMigrated = $input->getOption('add') ? true : false;
1996 if ( ! $configuration->hasVersion($version)) {
1997 throw MigrationException::unknownMigrationVersion($version);
2000 $version = $configuration->getVersion($version);
2001 if ($markMigrated && $configuration->hasVersionMigrated($version)) {
2002 throw new \InvalidArgumentException(sprintf('The version "%s" already exists in the version table.', $version));
2005 if ( ! $markMigrated && ! $configuration->hasVersionMigrated($version)) {
2006 throw new \InvalidArgumentException(sprintf('The version "%s" does not exists in the version table.', $version));
2009 if ($markMigrated) {
2010 $version->markMigrated();
2012 $version->markNotMigrated();
2020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2021 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2023 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2024 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2025 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2026 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2027 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2028 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2030 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2032 * This software consists of voluntary contributions made by many individuals
2033 * and is licensed under the LGPL. For more information, see
2034 * <http://www.doctrine-project.org>.
2037 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
2039 use Symfony\Component\Console\Input\InputInterface,
2040 Symfony\Component\Console\Output\OutputInterface,
2041 Symfony\Component\Console\Input\InputArgument,
2042 Symfony\Component\Console\Input\InputOption,
2043 Doctrine\DBAL\Migrations\Migration,
2044 Doctrine\DBAL\Migrations\Configuration\Configuration,
2045 Doctrine\DBAL\Migrations\Configuration\YamlConfiguration,
2046 Doctrine\DBAL\Migrations\Configuration\XmlConfiguration;
2049 * Command for executing single migrations up or down manually.
2051 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
2052 * @link www.doctrine-project.org
2054 * @version $Revision$
2055 * @author Jonathan Wage <jonwage@gmail.com>
2057 class ExecuteCommand extends AbstractCommand
2059 protected function configure()
2062 ->setName('migrations:execute')
2063 ->setDescription('Execute a single migration version up or down manually.')
2064 ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null)
2065 ->addOption('write-sql', null, InputOption::PARAMETER_NONE, 'The path to output the migration SQL file instead of executing it.')
2066 ->addOption('dry-run', null, InputOption::PARAMETER_NONE, 'Execute the migration as a dry run.')
2067 ->addOption('up', null, InputOption::PARAMETER_NONE, 'Execute the migration down.')
2068 ->addOption('down', null, InputOption::PARAMETER_NONE, 'Execute the migration down.')
2070 The <info>%command.name%</info> command executes a single migration version up or down manually:
2072 <info>%command.full_name% YYYYMMDDHHMMSS</info>
2074 If no <comment>--up</comment> or <comment>--down</comment> option is specified it defaults to up:
2076 <info>%command.full_name% YYYYMMDDHHMMSS --down</info>
2078 You can also execute the migration as a <comment>--dry-run</comment>:
2080 <info>%command.full_name% YYYYMMDDHHMMSS --dry-run</info>
2082 Or you can output the would be executed SQL statements to a file with <comment>--write-sql</comment>:
2084 <info>%command.full_name% YYYYMMDDHHMMSS --write-sql</info>
2088 parent::configure();
2091 public function execute(InputInterface $input, OutputInterface $output)
2093 $version = $input->getArgument('version');
2094 $direction = $input->getOption('down') ? 'down' : 'up';
2096 $configuration = $this->_getMigrationConfiguration($input, $output);
2097 $version = $configuration->getVersion($version);
2099 if ($path = $input->getOption('write-sql')) {
2100 $path = is_bool($path) ? getcwd() : $path;
2101 $version->writeSqlFile($path, $direction);
2103 $confirmation = $this->getHelper('dialog')->askConfirmation($output, '<question>WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)</question>', 'y');
2104 if ($confirmation === true) {
2105 $version->execute($direction, $input->getOption('dry-run') ? true : false);
2107 $output->writeln('<error>Migration cancelled!</error>');
2116 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2117 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2118 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2119 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2120 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2121 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2122 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2123 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2124 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2125 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2126 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2128 * This software consists of voluntary contributions made by many individuals
2129 * and is licensed under the LGPL. For more information, see
2130 * <http://www.doctrine-project.org>.
2133 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
2135 use Symfony\Component\Console\Input\InputInterface,
2136 Symfony\Component\Console\Output\OutputInterface,
2137 Symfony\Component\Console\Input\InputArgument,
2138 Symfony\Component\Console\Input\InputOption,
2139 Doctrine\DBAL\Migrations\Migration,
2140 Doctrine\DBAL\Migrations\MigrationException,
2141 Doctrine\DBAL\Migrations\Configuration\Configuration,
2142 Doctrine\DBAL\Migrations\Configuration\YamlConfiguration,
2143 Doctrine\DBAL\Migrations\Configuration\XmlConfiguration;
2146 * Command to view the status of a set of migrations.
2148 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
2149 * @link www.doctrine-project.org
2151 * @version $Revision$
2152 * @author Jonathan Wage <jonwage@gmail.com>
2154 class StatusCommand extends AbstractCommand
2156 protected function configure()
2159 ->setName('migrations:status')
2160 ->setDescription('View the status of a set of migrations.')
2161 ->addOption('show-versions', null, InputOption::PARAMETER_NONE, 'This will display a list of all available migrations and their status')
2163 The <info>%command.name%</info> command outputs the status of a set of migrations:
2165 <info>%command.full_name%</info>
2167 You can output a list of all available migrations and their status with <comment>--show-versions</comment>:
2169 <info>%command.full_name% --show-versions</info>
2173 parent::configure();
2176 public function execute(InputInterface $input, OutputInterface $output)
2178 $configuration = $this->_getMigrationConfiguration($input, $output);
2180 $currentVersion = $configuration->getCurrentVersion();
2181 if ($currentVersion) {
2182 $currentVersionFormatted = $configuration->formatVersion($currentVersion) . ' (<comment>'.$currentVersion.'</comment>)';
2184 $currentVersionFormatted = 0;
2186 $latestVersion = $configuration->getLatestVersion();
2187 if ($latestVersion) {
2188 $latestVersionFormatted = $configuration->formatVersion($latestVersion) . ' (<comment>'.$latestVersion.'</comment>)';
2190 $latestVersionFormatted = 0;
2192 $executedMigrations = $configuration->getNumberOfExecutedMigrations();
2193 $availableMigrations = $configuration->getNumberOfAvailableMigrations();
2194 $newMigrations = $availableMigrations - $executedMigrations;
2196 $output->writeln("\n <info>==</info> Configuration\n");
2199 'Name' => $configuration->getName() ? $configuration->getName() : 'Doctrine Database Migrations',
2200 'Database Driver' => $configuration->getConnection()->getDriver()->getName(),
2201 'Database Name' => $configuration->getConnection()->getDatabase(),
2202 'Configuration Source' => $configuration instanceof \Doctrine\DBAL\Migrations\Configuration\AbstractFileConfiguration ? $configuration->getFile() : 'manually configured',
2203 'Version Table Name' => $configuration->getMigrationsTableName(),
2204 'Migrations Namespace' => $configuration->getMigrationsNamespace(),
2205 'Migrations Directory' => $configuration->getMigrationsDirectory(),
2206 'Current Version' => $currentVersionFormatted,
2207 'Latest Version' => $latestVersionFormatted,
2208 'Executed Migrations' => $executedMigrations,
2209 'Available Migrations' => $availableMigrations,
2210 'New Migrations' => $newMigrations > 0 ? '<question>' . $newMigrations . '</question>' : $newMigrations
2212 foreach ($info as $name => $value) {
2213 $output->writeln(' <comment>>></comment> ' . $name . ': ' . str_repeat(' ', 50 - strlen($name)) . $value);
2216 $showVersions = $input->getOption('show-versions') ? true : false;
2217 if ($showVersions === true) {
2218 if ($migrations = $configuration->getMigrations()) {
2219 $output->writeln("\n <info>==</info> Migration Versions\n");
2220 foreach ($migrations as $version) {
2221 $isMigrated = $version->isMigrated();
2222 $status = $isMigrated ? '<info>migrated</info>' : '<error>not migrated</error>';
2223 $output->writeln(' <comment>>></comment> ' . $configuration->formatVersion($version->getVersion()) . ' (<comment>' . $version->getVersion() . '</comment>)' . str_repeat(' ', 30 - strlen($name)) . $status);
2233 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2234 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2235 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2236 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2237 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2238 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2239 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2240 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2241 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2242 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2243 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2245 * This software consists of voluntary contributions made by many individuals
2246 * and is licensed under the LGPL. For more information, see
2247 * <http://www.doctrine-project.org>.
2250 namespace Doctrine\DBAL\Migrations\Tools\Console\Command;
2252 use Symfony\Component\Console\Input\InputInterface,
2253 Symfony\Component\Console\Output\OutputInterface,
2254 Symfony\Component\Console\Input\InputArgument,
2255 Symfony\Component\Console\Input\InputOption,
2256 Doctrine\DBAL\Migrations\Migration,
2257 Doctrine\DBAL\Migrations\Configuration\Configuration,
2258 Doctrine\DBAL\Migrations\Configuration\YamlConfiguration,
2259 Doctrine\DBAL\Migrations\Configuration\XmlConfiguration;
2262 * Command for executing a migration to a specified version or the latest available version.
2264 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
2265 * @link www.doctrine-project.org
2267 * @version $Revision$
2268 * @author Jonathan Wage <jonwage@gmail.com>
2270 class MigrateCommand extends AbstractCommand
2272 protected function configure()
2275 ->setName('migrations:migrate')
2276 ->setDescription('Execute a migration to a specified version or the latest available version.')
2277 ->addArgument('version', InputArgument::OPTIONAL, 'The version to migrate to.', null)
2278 ->addOption('write-sql', null, InputOption::PARAMETER_NONE, 'The path to output the migration SQL file instead of executing it.')
2279 ->addOption('dry-run', null, InputOption::PARAMETER_NONE, 'Execute the migration as a dry run.')
2281 The <info>%command.name%</info> command executes a migration to a specified version or the latest available version:
2283 <info>%command.full_name%</info>
2285 You can optionally manually specify the version you wish to migrate to:
2287 <info>%command.full_name% YYYYMMDDHHMMSS</info>
2289 You can also execute the migration as a <comment>--dry-run</comment>:
2291 <info>%command.full_name% YYYYMMDDHHMMSS --dry-run</info>
2293 Or you can output the would be executed SQL statements to a file with <comment>--write-sql</comment>:
2295 <info>%command.full_name% YYYYMMDDHHMMSS --write-sql</info>
2297 You can also execute the migration without a warning message wich you need to interact with:
2299 <info>%command.full_name% --no-interaction</info>
2304 parent::configure();
2307 public function execute(InputInterface $input, OutputInterface $output)
2309 $version = $input->getArgument('version');
2311 $configuration = $this->_getMigrationConfiguration($input, $output);
2312 $migration = new Migration($configuration);
2314 $this->_outputHeader($configuration, $output);
2316 if ($path = $input->getOption('write-sql')) {
2317 $path = is_bool($path) ? getcwd() : $path;
2318 $migration->writeSqlFile($path, $version);
2320 $dryRun = $input->getOption('dry-run') ? true : false;
2321 if ($dryRun === true) {
2322 $migration->migrate($version, true);
2324 $noInteraction = $input->getOption('no-interaction') ? true : false;
2325 if ($noInteraction === true) {
2326 $migration->migrate($version, $dryRun);
2328 $confirmation = $this->getHelper('dialog')->askConfirmation($output, '<question>WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)</question>', 'y');
2329 if ($confirmation === true) {
2330 $migration->migrate($version, $dryRun);
2332 $output->writeln('<error>Migration cancelled!</error>');
2341 namespace Doctrine\DBAL;
2343 class DBALException extends \Exception
2345 public static function notSupported($method)
2347 return new self("Operation '$method' is not supported by platform.");
2350 public static function invalidPlatformSpecified()
2353 "Invalid 'platform' option specified, need to give an instance of ".
2354 "\Doctrine\DBAL\Platforms\AbstractPlatform.");
2357 public static function invalidPdoInstance()
2360 "The 'pdo' option was used in DriverManager::getConnection() but no ".
2361 "instance of PDO was given."
2365 public static function driverRequired()
2367 return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ".
2368 "instance is given to DriverManager::getConnection().");
2371 public static function unknownDriver($unknownDriverName, array $knownDrivers)
2373 return new self("The given 'driver' ".$unknownDriverName." is unknown, ".
2374 "Doctrine currently supports only the following drivers: ".implode(", ", $knownDrivers));
2377 public static function invalidWrapperClass($wrapperClass)
2379 return new self("The given 'wrapperClass' ".$wrapperClass." has to be a ".
2380 "subtype of \Doctrine\DBAL\Connection.");
2383 public static function invalidDriverClass($driverClass)
2385 return new self("The given 'driverClass' ".$driverClass." has to implement the ".
2386 "\Doctrine\DBAL\Driver interface.");
2390 * @param string $tableName
2391 * @return DBALException
2393 public static function invalidTableName($tableName)
2395 return new self("Invalid table name specified: ".$tableName);
2399 * @param string $tableName
2400 * @return DBALException
2402 public static function noColumnsSpecifiedForTable($tableName)
2404 return new self("No columns specified for table ".$tableName);
2407 public static function limitOffsetInvalid()
2409 return new self("Invalid Offset in Limit Query, it has to be larger or equal to 0.");
2412 public static function typeExists($name)
2414 return new self('Type '.$name.' already exists.');
2417 public static function unknownColumnType($name)
2419 return new self('Unknown column type '.$name.' requested.');
2422 public static function typeNotFound($name)
2424 return new self('Type to be overwritten '.$name.' does not exist.');
2430 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2431 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2432 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2433 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2434 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2435 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2436 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2437 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2438 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2439 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2440 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2442 * This software consists of voluntary contributions made by many individuals
2443 * and is licensed under the LGPL. For more information, see
2444 * <http://www.doctrine-project.org>.
2447 namespace Doctrine\DBAL\Driver\PDOOracle;
2449 use Doctrine\DBAL\Platforms;
2451 class Driver implements \Doctrine\DBAL\Driver
2453 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
2455 return new \Doctrine\DBAL\Driver\PDOConnection(
2456 $this->_constructPdoDsn($params),
2464 * Constructs the Oracle PDO DSN.
2466 * @return string The DSN.
2468 private function _constructPdoDsn(array $params)
2471 if (isset($params['host'])) {
2472 $dsn .= 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)' .
2473 '(HOST=' . $params['host'] . ')';
2475 if (isset($params['port'])) {
2476 $dsn .= '(PORT=' . $params['port'] . ')';
2478 $dsn .= '(PORT=1521)';
2481 $dsn .= '))(CONNECT_DATA=(SID=' . $params['dbname'] . ')))';
2483 $dsn .= 'dbname=' . $params['dbname'];
2486 if (isset($params['charset'])) {
2487 $dsn .= ';charset=' . $params['charset'];
2493 public function getDatabasePlatform()
2495 return new \Doctrine\DBAL\Platforms\OraclePlatform();
2498 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
2500 return new \Doctrine\DBAL\Schema\OracleSchemaManager($conn);
2503 public function getName()
2505 return 'pdo_oracle';
2508 public function getDatabase(\Doctrine\DBAL\Connection $conn)
2510 $params = $conn->getParams();
2511 return $params['user'];
2517 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2518 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2519 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2520 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2521 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2522 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2523 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2524 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2525 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2526 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2527 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2529 * This software consists of voluntary contributions made by many individuals
2530 * and is licensed under the LGPL. For more information, see
2531 * <http://www.doctrine-project.org>.
2534 namespace Doctrine\DBAL\Driver\IBMDB2;
2536 class DB2Connection implements \Doctrine\DBAL\Driver\Connection
2538 private $_conn = null;
2540 public function __construct(array $params, $username, $password, $driverOptions = array())
2542 $isPersistant = (isset($params['persistent']) && $params['persistent'] == true);
2544 if ($isPersistant) {
2545 $this->_conn = db2_pconnect($params['dbname'], $username, $password, $driverOptions);
2547 $this->_conn = db2_connect($params['dbname'], $username, $password, $driverOptions);
2549 if (!$this->_conn) {
2550 throw new DB2Exception(db2_conn_errormsg());
2554 function prepare($sql)
2556 $stmt = @db2_prepare($this->_conn, $sql);
2558 throw new DB2Exception(db2_stmt_errormsg());
2560 return new DB2Statement($stmt);
2565 $args = func_get_args();
2567 $stmt = $this->prepare($sql);
2572 function quote($input, $type=\PDO::PARAM_STR)
2574 $input = db2_escape_string($input);
2575 if ($type == \PDO::PARAM_INT ) {
2578 return "'".$input."'";
2582 function exec($statement)
2584 $stmt = $this->prepare($statement);
2586 return $stmt->rowCount();
2589 function lastInsertId($name = null)
2591 return db2_last_insert_id($this->_conn);
2594 function beginTransaction()
2596 db2_autocommit($this->_conn, DB2_AUTOCOMMIT_OFF);
2601 if (!db2_commit($this->_conn)) {
2602 throw new DB2Exception(db2_conn_errormsg($this->_conn));
2604 db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON);
2609 if (!db2_rollback($this->_conn)) {
2610 throw new DB2Exception(db2_conn_errormsg($this->_conn));
2612 db2_autocommit($this->_conn, DB2_AUTOCOMMIT_ON);
2615 function errorCode()
2617 return db2_conn_error($this->_conn);
2620 function errorInfo()
2623 0 => db2_conn_errormsg($this->_conn),
2624 1 => $this->errorCode(),
2631 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2632 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2633 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2634 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2635 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2636 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2637 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2638 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2639 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2640 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2641 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2643 * This software consists of voluntary contributions made by many individuals
2644 * and is licensed under the LGPL. For more information, see
2645 * <http://www.doctrine-project.org>.
2648 namespace Doctrine\DBAL\Driver\IBMDB2;
2650 class DB2Statement implements \Doctrine\DBAL\Driver\Statement
2652 private $_stmt = null;
2654 private $_bindParam = array();
2657 * DB2_BINARY, DB2_CHAR, DB2_DOUBLE, or DB2_LONG
2660 static private $_typeMap = array(
2661 \PDO::PARAM_INT => DB2_LONG,
2662 \PDO::PARAM_STR => DB2_CHAR,
2665 public function __construct($stmt)
2667 $this->_stmt = $stmt;
2671 * Binds a value to a corresponding named or positional
2672 * placeholder in the SQL statement that was used to prepare the statement.
2674 * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
2675 * this will be a parameter name of the form :name. For a prepared statement
2676 * using question mark placeholders, this will be the 1-indexed position of the parameter
2678 * @param mixed $value The value to bind to the parameter.
2679 * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
2681 * @return boolean Returns TRUE on success or FALSE on failure.
2683 function bindValue($param, $value, $type = null)
2685 return $this->bindParam($param, $value, $type);
2689 * Binds a PHP variable to a corresponding named or question mark placeholder in the
2690 * SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
2691 * the variable is bound as a reference and will only be evaluated at the time
2692 * that PDOStatement->execute() is called.
2694 * Most parameters are input parameters, that is, parameters that are
2695 * used in a read-only fashion to build up the query. Some drivers support the invocation
2696 * of stored procedures that return data as output parameters, and some also as input/output
2697 * parameters that both send in data and are updated to receive it.
2699 * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
2700 * this will be a parameter name of the form :name. For a prepared statement
2701 * using question mark placeholders, this will be the 1-indexed position of the parameter
2703 * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
2705 * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
2706 * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
2707 * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
2708 * @return boolean Returns TRUE on success or FALSE on failure.
2710 function bindParam($column, &$variable, $type = null)
2712 $this->_bindParam[$column] =& $variable;
2714 if ($type && isset(self::$_typeMap[$type])) {
2715 $type = self::$_typeMap[$type];
2720 if (!db2_bind_param($this->_stmt, $column, "variable", DB2_PARAM_IN, $type)) {
2721 throw new DB2Exception(db2_stmt_errormsg());
2727 * Closes the cursor, enabling the statement to be executed again.
2729 * @return boolean Returns TRUE on success or FALSE on failure.
2731 function closeCursor()
2733 if (!$this->_stmt) {
2737 $this->_bindParam = array();
2738 db2_free_result($this->_stmt);
2739 $ret = db2_free_stmt($this->_stmt);
2740 $this->_stmt = false;
2746 * Returns the number of columns in the result set
2748 * @return integer Returns the number of columns in the result set represented
2749 * by the PDOStatement object. If there is no result set,
2750 * this method should return 0.
2752 function columnCount()
2754 if (!$this->_stmt) {
2757 return db2_num_fields($this->_stmt);
2762 * Fetch the SQLSTATE associated with the last operation on the statement handle
2764 * @see Doctrine_Adapter_Interface::errorCode()
2765 * @return string error code string
2767 function errorCode()
2769 return db2_stmt_error();
2774 * Fetch extended error information associated with the last operation on the statement handle
2776 * @see Doctrine_Adapter_Interface::errorInfo()
2777 * @return array error info array
2779 function errorInfo()
2782 0 => db2_stmt_errormsg(),
2783 1 => db2_stmt_error(),
2788 * Executes a prepared statement
2790 * If the prepared statement included parameter markers, you must either:
2791 * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
2792 * bound variables pass their value as input and receive the output value,
2793 * if any, of their associated parameter markers or pass an array of input-only
2797 * @param array $params An array of values with as many elements as there are
2798 * bound parameters in the SQL statement being executed.
2799 * @return boolean Returns TRUE on success or FALSE on failure.
2801 function execute($params = null)
2803 if (!$this->_stmt) {
2808 if ($params !== null) {
2809 $retval = @db2_execute($this->_stmt, $params);
2811 $retval = @db2_execute($this->_stmt);
2813 if ($params === null) {
2814 ksort($this->_bindParam);
2815 $params = array_values($this->_bindParam);
2817 $retval = @db2_execute($this->_stmt, $params);
2819 if ($retval === false) {
2820 throw new DB2Exception(db2_stmt_errormsg());
2828 * @see Query::HYDRATE_* constants
2829 * @param integer $fetchStyle Controls how the next row will be returned to the caller.
2830 * This value must be one of the Query::HYDRATE_* constants,
2831 * defaulting to Query::HYDRATE_BOTH
2833 * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
2834 * this value determines which row will be returned to the caller.
2835 * This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
2836 * Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
2837 * PDOStatement object,
2838 * you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
2839 * prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
2841 * @param integer $cursorOffset For a PDOStatement object representing a scrollable cursor for which the
2842 * $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
2843 * the absolute number of the row in the result set that shall be fetched.
2845 * For a PDOStatement object representing a scrollable cursor for
2846 * which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
2847 * specifies the row to fetch relative to the cursor position before
2848 * PDOStatement->fetch() was called.
2852 function fetch($fetchStyle = \PDO::FETCH_BOTH)
2854 switch ($fetchStyle) {
2855 case \PDO::FETCH_BOTH:
2856 return db2_fetch_both($this->_stmt);
2857 case \PDO::FETCH_ASSOC:
2858 return db2_fetch_assoc($this->_stmt);
2859 case \PDO::FETCH_NUM:
2860 return db2_fetch_array($this->_stmt);
2862 throw new DB2Exception("Given Fetch-Style " . $fetchStyle . " is not supported.");
2867 * Returns an array containing all of the result set rows
2869 * @param integer $fetchStyle Controls how the next row will be returned to the caller.
2870 * This value must be one of the Query::HYDRATE_* constants,
2871 * defaulting to Query::HYDRATE_BOTH
2873 * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
2874 * Query::HYDRATE_COLUMN. Defaults to 0.
2878 function fetchAll($fetchStyle = \PDO::FETCH_BOTH)
2881 while ($row = $this->fetch($fetchStyle)) {
2889 * Returns a single column from the next row of a
2890 * result set or FALSE if there are no more rows.
2892 * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
2893 * value is supplied, PDOStatement->fetchColumn()
2894 * fetches the first column.
2896 * @return string returns a single column in the next row of a result set.
2898 function fetchColumn($columnIndex = 0)
2900 $row = $this->fetch(\PDO::FETCH_NUM);
2901 if ($row && isset($row[$columnIndex])) {
2902 return $row[$columnIndex];
2909 * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
2910 * executed by the corresponding object.
2912 * If the last SQL statement executed by the associated Statement object was a SELECT statement,
2913 * some databases may return the number of rows returned by that statement. However,
2914 * this behaviour is not guaranteed for all databases and should not be
2915 * relied on for portable applications.
2917 * @return integer Returns the number of rows.
2921 return (@db2_num_rows($this->_stmt))?:0;
2928 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2929 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2930 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2931 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2932 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2933 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2934 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2935 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2936 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2937 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2938 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2940 * This software consists of voluntary contributions made by many individuals
2941 * and is licensed under the LGPL. For more information, see
2942 * <http://www.doctrine-project.org>.
2945 namespace Doctrine\DBAL\Driver\IBMDB2;
2947 class DB2Exception extends \Exception
2952 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2953 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2954 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2955 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2956 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2957 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2958 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2959 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2960 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2961 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2962 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2964 * This software consists of voluntary contributions made by many individuals
2965 * and is licensed under the LGPL. For more information, see
2966 * <http://www.doctrine-project.org>.
2969 namespace Doctrine\DBAL\Driver\IBMDB2;
2971 use Doctrine\DBAL\Driver,
2972 Doctrine\DBAL\Connection;
2978 * @author Benjamin Eberlei <kontakt@beberlei.de>
2980 class DB2Driver implements Driver
2983 * Attempts to create a connection with the database.
2985 * @param array $params All connection parameters passed by the user.
2986 * @param string $username The username to use when connecting.
2987 * @param string $password The password to use when connecting.
2988 * @param array $driverOptions The driver options to use when connecting.
2989 * @return Doctrine\DBAL\Driver\Connection The database connection.
2991 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
2993 if ( !isset($params['schema']) ) {
2997 if ($params['host'] !== 'localhost' && $params['host'] != '127.0.0.1') {
2998 // if the host isn't localhost, use extended connection params
2999 $params['dbname'] = 'DRIVER={IBM DB2 ODBC DRIVER}' .
3000 ';DATABASE=' . $params['dbname'] .
3001 ';HOSTNAME=' . $params['host'] .
3002 ';PORT=' . $params['port'] .
3003 ';PROTOCOL=' . $params['protocol'] .
3004 ';UID=' . $username .
3005 ';PWD=' . $password .';';
3010 return new DB2Connection($params, $username, $password, $driverOptions);
3014 * Gets the DatabasePlatform instance that provides all the metadata about
3015 * the platform this driver connects to.
3017 * @return Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
3019 public function getDatabasePlatform()
3021 return new \Doctrine\DBAL\Platforms\DB2Platform;
3025 * Gets the SchemaManager that can be used to inspect and change the underlying
3026 * database schema of the platform this driver connects to.
3028 * @param Doctrine\DBAL\Connection $conn
3029 * @return Doctrine\DBAL\SchemaManager
3031 public function getSchemaManager(Connection $conn)
3033 return new \Doctrine\DBAL\Schema\DB2SchemaManager($conn);
3037 * Gets the name of the driver.
3039 * @return string The name of the driver.
3041 public function getName()
3047 * Get the name of the database connected to for this driver.
3049 * @param Doctrine\DBAL\Connection $conn
3050 * @return string $database
3052 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3054 $params = $conn->getParams();
3055 return $params['dbname'];
3060 * $Id: Interface.php 3882 2008-02-22 18:11:35Z jwage $
3062 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3063 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3064 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3065 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3066 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3067 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3068 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3069 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3070 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3071 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3072 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3074 * This software consists of voluntary contributions made by many individuals
3075 * and is licensed under the LGPL. For more information, see
3076 * <http://www.doctrine-project.org>.
3079 namespace Doctrine\DBAL\Driver;
3082 * The PDO implementation of the Statement interface.
3083 * Used by all PDO-based drivers.
3087 class PDOStatement extends \PDOStatement implements Statement
3089 private function __construct() {}
3094 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3095 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3096 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3097 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3098 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3099 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3100 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3101 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3102 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3103 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3104 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3106 * This software consists of voluntary contributions made by many individuals
3107 * and is licensed under the LGPL. For more information, see
3108 * <http://www.doctrine-project.org>.
3111 namespace Doctrine\DBAL\Driver\PDOMsSql;
3114 * The PDO-based MsSql driver.
3118 class Driver implements \Doctrine\DBAL\Driver
3120 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
3122 return new Connection(
3123 $this->_constructPdoDsn($params),
3131 * Constructs the MsSql PDO DSN.
3133 * @return string The DSN.
3135 private function _constructPdoDsn(array $params)
3137 // TODO: This might need to be revisted once we have access to a mssql server
3139 if (isset($params['host'])) {
3140 $dsn .= 'host=' . $params['host'] . ';';
3142 if (isset($params['port'])) {
3143 $dsn .= 'port=' . $params['port'] . ';';
3145 if (isset($params['dbname'])) {
3146 $dsn .= 'dbname=' . $params['dbname'] . ';';
3153 public function getDatabasePlatform()
3155 return new \Doctrine\DBAL\Platforms\MsSqlPlatform();
3158 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
3160 return new \Doctrine\DBAL\Schema\MsSqlSchemaManager($conn);
3163 public function getName()
3168 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3170 $params = $conn->getParams();
3171 return $params['dbname'];
3177 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3178 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3179 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3180 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3181 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3182 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3183 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3184 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3185 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3186 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3187 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3189 * This software consists of voluntary contributions made by many individuals
3190 * and is licensed under the LGPL. For more information, see
3191 * <http://www.doctrine-project.org>.
3194 namespace Doctrine\DBAL\Driver\PDOMsSql;
3197 * MsSql Connection implementation.
3201 class Connection extends \PDO implements \Doctrine\DBAL\Driver\Connection
3204 * Performs the rollback.
3208 public function rollback()
3210 $this->exec('ROLLBACK TRANSACTION');
3214 * Performs the commit.
3218 public function commit()
3220 $this->exec('COMMIT TRANSACTION');
3224 * Begins a database transaction.
3228 public function beginTransaction()
3230 $this->exec('BEGIN TRANSACTION');
3236 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3237 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3238 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3239 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3240 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3241 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3242 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3243 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3244 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3245 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3246 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3248 * This software consists of voluntary contributions made by many individuals
3249 * and is licensed under the LGPL. For more information, see
3250 * <http://www.doctrine-project.org>.
3253 namespace Doctrine\DBAL\Driver;
3258 * Statement interface.
3259 * Drivers must implement this interface.
3261 * This resembles (a subset of) the PDOStatement interface.
3263 * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
3264 * @author Roman Borschel <roman@code-factory.org>
3265 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
3266 * @link www.doctrine-project.org
3268 * @version $Revision$
3273 * Binds a value to a corresponding named or positional
3274 * placeholder in the SQL statement that was used to prepare the statement.
3276 * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
3277 * this will be a parameter name of the form :name. For a prepared statement
3278 * using question mark placeholders, this will be the 1-indexed position of the parameter
3280 * @param mixed $value The value to bind to the parameter.
3281 * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
3283 * @return boolean Returns TRUE on success or FALSE on failure.
3285 function bindValue($param, $value, $type = null);
3288 * Binds a PHP variable to a corresponding named or question mark placeholder in the
3289 * SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
3290 * the variable is bound as a reference and will only be evaluated at the time
3291 * that PDOStatement->execute() is called.
3293 * Most parameters are input parameters, that is, parameters that are
3294 * used in a read-only fashion to build up the query. Some drivers support the invocation
3295 * of stored procedures that return data as output parameters, and some also as input/output
3296 * parameters that both send in data and are updated to receive it.
3298 * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
3299 * this will be a parameter name of the form :name. For a prepared statement
3300 * using question mark placeholders, this will be the 1-indexed position of the parameter
3302 * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
3304 * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
3305 * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
3306 * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
3307 * @return boolean Returns TRUE on success or FALSE on failure.
3309 function bindParam($column, &$variable, $type = null);
3312 * Closes the cursor, enabling the statement to be executed again.
3314 * @return boolean Returns TRUE on success or FALSE on failure.
3316 function closeCursor();
3320 * Returns the number of columns in the result set
3322 * @return integer Returns the number of columns in the result set represented
3323 * by the PDOStatement object. If there is no result set,
3324 * this method should return 0.
3326 function columnCount();
3330 * Fetch the SQLSTATE associated with the last operation on the statement handle
3332 * @see Doctrine_Adapter_Interface::errorCode()
3333 * @return string error code string
3335 function errorCode();
3339 * Fetch extended error information associated with the last operation on the statement handle
3341 * @see Doctrine_Adapter_Interface::errorInfo()
3342 * @return array error info array
3344 function errorInfo();
3347 * Executes a prepared statement
3349 * If the prepared statement included parameter markers, you must either:
3350 * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
3351 * bound variables pass their value as input and receive the output value,
3352 * if any, of their associated parameter markers or pass an array of input-only
3356 * @param array $params An array of values with as many elements as there are
3357 * bound parameters in the SQL statement being executed.
3358 * @return boolean Returns TRUE on success or FALSE on failure.
3360 function execute($params = null);
3365 * @see Query::HYDRATE_* constants
3366 * @param integer $fetchStyle Controls how the next row will be returned to the caller.
3367 * This value must be one of the Query::HYDRATE_* constants,
3368 * defaulting to Query::HYDRATE_BOTH
3370 * @param integer $cursorOrientation For a PDOStatement object representing a scrollable cursor,
3371 * this value determines which row will be returned to the caller.
3372 * This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
3373 * Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
3374 * PDOStatement object,
3375 * you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
3376 * prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
3378 * @param integer $cursorOffset For a PDOStatement object representing a scrollable cursor for which the
3379 * $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
3380 * the absolute number of the row in the result set that shall be fetched.
3382 * For a PDOStatement object representing a scrollable cursor for
3383 * which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
3384 * specifies the row to fetch relative to the cursor position before
3385 * PDOStatement->fetch() was called.
3389 function fetch($fetchStyle = PDO::FETCH_BOTH);
3392 * Returns an array containing all of the result set rows
3394 * @param integer $fetchStyle Controls how the next row will be returned to the caller.
3395 * This value must be one of the Query::HYDRATE_* constants,
3396 * defaulting to Query::HYDRATE_BOTH
3398 * @param integer $columnIndex Returns the indicated 0-indexed column when the value of $fetchStyle is
3399 * Query::HYDRATE_COLUMN. Defaults to 0.
3403 function fetchAll($fetchStyle = PDO::FETCH_BOTH);
3407 * Returns a single column from the next row of a
3408 * result set or FALSE if there are no more rows.
3410 * @param integer $columnIndex 0-indexed number of the column you wish to retrieve from the row. If no
3411 * value is supplied, PDOStatement->fetchColumn()
3412 * fetches the first column.
3414 * @return string returns a single column in the next row of a result set.
3416 function fetchColumn($columnIndex = 0);
3420 * rowCount() returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
3421 * executed by the corresponding object.
3423 * If the last SQL statement executed by the associated Statement object was a SELECT statement,
3424 * some databases may return the number of rows returned by that statement. However,
3425 * this behaviour is not guaranteed for all databases and should not be
3426 * relied on for portable applications.
3428 * @return integer Returns the number of rows.
3430 function rowCount();
3433 namespace Doctrine\DBAL\Driver\PDOPgSql;
3435 use Doctrine\DBAL\Platforms;
3438 * Driver that connects through pdo_pgsql.
3442 class Driver implements \Doctrine\DBAL\Driver
3445 * Attempts to connect to the database and returns a driver connection on success.
3447 * @return Doctrine\DBAL\Driver\Connection
3449 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
3451 return new \Doctrine\DBAL\Driver\PDOConnection(
3452 $this->_constructPdoDsn($params),
3460 * Constructs the Postgres PDO DSN.
3462 * @return string The DSN.
3464 private function _constructPdoDsn(array $params)
3467 if (isset($params['host'])) {
3468 $dsn .= 'host=' . $params['host'] . ' ';
3470 if (isset($params['port'])) {
3471 $dsn .= 'port=' . $params['port'] . ' ';
3473 if (isset($params['dbname'])) {
3474 $dsn .= 'dbname=' . $params['dbname'] . ' ';
3480 public function getDatabasePlatform()
3482 return new \Doctrine\DBAL\Platforms\PostgreSqlPlatform();
3485 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
3487 return new \Doctrine\DBAL\Schema\PostgreSqlSchemaManager($conn);
3490 public function getName()
3495 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3497 $params = $conn->getParams();
3498 return $params['dbname'];
3504 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3505 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3506 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3507 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3508 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3509 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3510 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3511 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3512 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3513 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3514 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3516 * This software consists of voluntary contributions made by many individuals
3517 * and is licensed under the LGPL. For more information, see
3518 * <http://www.doctrine-project.org>.
3521 namespace Doctrine\DBAL\Driver;
3526 * PDO implementation of the Connection interface.
3527 * Used by all PDO-based drivers.
3531 class PDOConnection extends PDO implements Connection
3533 public function __construct($dsn, $user = null, $password = null, array $options = null)
3535 parent::__construct($dsn, $user, $password, $options);
3536 $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Doctrine\DBAL\Driver\PDOStatement', array()));
3537 $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
3543 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3544 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3545 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3546 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3547 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3548 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3549 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3550 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3551 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3552 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3553 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3555 * This software consists of voluntary contributions made by many individuals
3556 * and is licensed under the LGPL. For more information, see
3557 * <http://www.doctrine-project.org>.
3560 namespace Doctrine\DBAL\Driver\PDOIbm;
3562 use Doctrine\DBAL\Connection;
3565 * Driver for the PDO IBM extension
3567 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
3568 * @link www.doctrine-project.com
3570 * @version $Revision$
3571 * @author Benjamin Eberlei <kontakt@beberlei.de>
3572 * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
3573 * @author Jonathan Wage <jonwage@gmail.com>
3574 * @author Roman Borschel <roman@code-factory.org>
3576 class Driver implements \Doctrine\DBAL\Driver
3579 * Attempts to establish a connection with the underlying driver.
3581 * @param array $params
3582 * @param string $username
3583 * @param string $password
3584 * @param array $driverOptions
3585 * @return Doctrine\DBAL\Driver\Connection
3587 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
3589 $conn = new \Doctrine\DBAL\Driver\PDOConnection(
3590 $this->_constructPdoDsn($params),
3599 * Constructs the MySql PDO DSN.
3601 * @return string The DSN.
3603 private function _constructPdoDsn(array $params)
3606 if (isset($params['host'])) {
3607 $dsn .= 'HOSTNAME=' . $params['host'] . ';';
3609 if (isset($params['port'])) {
3610 $dsn .= 'PORT=' . $params['port'] . ';';
3612 $dsn .= 'PROTOCOL=TCPIP;';
3613 if (isset($params['dbname'])) {
3614 $dsn .= 'DATABASE=' . $params['dbname'] . ';';
3621 * Gets the DatabasePlatform instance that provides all the metadata about
3622 * the platform this driver connects to.
3624 * @return Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
3626 public function getDatabasePlatform()
3628 return new \Doctrine\DBAL\Platforms\DB2Platform;
3632 * Gets the SchemaManager that can be used to inspect and change the underlying
3633 * database schema of the platform this driver connects to.
3635 * @param Doctrine\DBAL\Connection $conn
3636 * @return Doctrine\DBAL\SchemaManager
3638 public function getSchemaManager(Connection $conn)
3640 return new \Doctrine\DBAL\Schema\DB2SchemaManager($conn);
3644 * Gets the name of the driver.
3646 * @return string The name of the driver.
3648 public function getName()
3654 * Get the name of the database connected to for this driver.
3656 * @param Doctrine\DBAL\Connection $conn
3657 * @return string $database
3659 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3661 $params = $conn->getParams();
3662 return $params['dbname'];
3666 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3667 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3668 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3669 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3670 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3671 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3672 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3673 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3674 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3675 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3676 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3678 * This software consists of voluntary contributions made by many individuals
3679 * and is licensed under the LGPL. For more information, see
3680 * <http://www.doctrine-project.org>.
3683 namespace Doctrine\DBAL\Driver\PDOMySql;
3685 use Doctrine\DBAL\Connection;
3692 class Driver implements \Doctrine\DBAL\Driver
3695 * Attempts to establish a connection with the underlying driver.
3697 * @param array $params
3698 * @param string $username
3699 * @param string $password
3700 * @param array $driverOptions
3701 * @return Doctrine\DBAL\Driver\Connection
3703 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
3705 $conn = new \Doctrine\DBAL\Driver\PDOConnection(
3706 $this->_constructPdoDsn($params),
3715 * Constructs the MySql PDO DSN.
3717 * @return string The DSN.
3719 private function _constructPdoDsn(array $params)
3722 if (isset($params['host'])) {
3723 $dsn .= 'host=' . $params['host'] . ';';
3725 if (isset($params['port'])) {
3726 $dsn .= 'port=' . $params['port'] . ';';
3728 if (isset($params['dbname'])) {
3729 $dsn .= 'dbname=' . $params['dbname'] . ';';
3731 if (isset($params['unix_socket'])) {
3732 $dsn .= 'unix_socket=' . $params['unix_socket'] . ';';
3738 public function getDatabasePlatform()
3740 return new \Doctrine\DBAL\Platforms\MySqlPlatform();
3743 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
3745 return new \Doctrine\DBAL\Schema\MySqlSchemaManager($conn);
3748 public function getName()
3753 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3755 $params = $conn->getParams();
3756 return $params['dbname'];
3762 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3763 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3764 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3765 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3766 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3767 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3768 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3769 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3770 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3771 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3772 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3774 * This software consists of voluntary contributions made by many individuals
3775 * and is licensed under the LGPL. For more information, see
3776 * <http://www.doctrine-project.org>.
3779 namespace Doctrine\DBAL\Driver\PDOSqlsrv;
3782 * The PDO-based Sqlsrv driver.
3786 class Driver implements \Doctrine\DBAL\Driver
3788 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
3790 return new \Doctrine\DBAL\Driver\PDOConnection(
3791 $this->_constructPdoDsn($params),
3799 * Constructs the Sqlsrv PDO DSN.
3801 * @return string The DSN.
3803 private function _constructPdoDsn(array $params)
3805 $dsn = 'sqlsrv:server=';
3807 if (isset($params['host'])) {
3808 $dsn .= $params['host'];
3811 if (isset($params['port']) && !empty($params['port'])) {
3812 $dsn .= ',' . $params['port'];
3815 if (isset($params['dbname'])) {
3816 $dsn .= ';Database=' . $params['dbname'];
3823 public function getDatabasePlatform()
3825 return new \Doctrine\DBAL\Platforms\MsSqlPlatform();
3828 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
3830 return new \Doctrine\DBAL\Schema\MsSqlSchemaManager($conn);
3833 public function getName()
3835 return 'pdo_sqlsrv';
3838 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3840 $params = $conn->getParams();
3841 return $params['dbname'];
3845 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3846 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3847 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3848 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3849 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3850 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3851 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3852 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3853 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3854 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3855 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3857 * This software consists of voluntary contributions made by many individuals
3858 * and is licensed under the LGPL. For more information, see
3859 * <http://www.doctrine-project.org>.
3862 namespace Doctrine\DBAL\Driver\PDOSqlite;
3865 * The PDO Sqlite driver.
3869 class Driver implements \Doctrine\DBAL\Driver
3874 protected $_userDefinedFunctions = array(
3875 'sqrt' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'), 'numArgs' => 1),
3876 'mod' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'), 'numArgs' => 2),
3877 'locate' => array('callback' => array('Doctrine\DBAL\Platforms\SqlitePlatform', 'udfLocate'), 'numArgs' => -1),
3881 * Tries to establish a database connection to SQLite.
3883 * @param array $params
3884 * @param string $username
3885 * @param string $password
3886 * @param array $driverOptions
3887 * @return Connection
3889 public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
3891 if (isset($driverOptions['userDefinedFunctions'])) {
3892 $this->_userDefinedFunctions = array_merge(
3893 $this->_userDefinedFunctions, $driverOptions['userDefinedFunctions']);
3894 unset($driverOptions['userDefinedFunctions']);
3897 $pdo = new \Doctrine\DBAL\Driver\PDOConnection(
3898 $this->_constructPdoDsn($params),
3904 foreach ($this->_userDefinedFunctions AS $fn => $data) {
3905 $pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']);
3912 * Constructs the Sqlite PDO DSN.
3914 * @return string The DSN.
3917 protected function _constructPdoDsn(array $params)
3920 if (isset($params['path'])) {
3921 $dsn .= $params['path'];
3922 } else if (isset($params['memory'])) {
3930 * Gets the database platform that is relevant for this driver.
3932 public function getDatabasePlatform()
3934 return new \Doctrine\DBAL\Platforms\SqlitePlatform();
3938 * Gets the schema manager that is relevant for this driver.
3940 * @param Doctrine\DBAL\Connection $conn
3941 * @return Doctrine\DBAL\Schema\SqliteSchemaManager
3943 public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
3945 return new \Doctrine\DBAL\Schema\SqliteSchemaManager($conn);
3948 public function getName()
3950 return 'pdo_sqlite';
3953 public function getDatabase(\Doctrine\DBAL\Connection $conn)
3955 $params = $conn->getParams();
3956 return isset($params['path']) ? $params['path'] : null;
3962 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3963 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3964 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3965 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3966 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3967 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3968 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3969 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3970 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3971 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3972 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3974 * This software consists of voluntary contributions made by many individuals
3975 * and is licensed under the LGPL. For more information, see
3976 * <http://www.doctrine-project.org>.
3979 namespace Doctrine\DBAL\Driver\OCI8;
3981 class OCI8Exception extends \Exception
3983 static public function fromErrorInfo($error)
3985 return new self($error['message'], $error['code']);
3992 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3993 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3994 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3995 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3996 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,