Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
45079a1e
Commit
45079a1e
authored
Feb 17, 2009
by
jwage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Refactoring ClassExporter to allow the getting of the generated sql as well as executing it
parent
438d970f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
UPGRADE_TO_2_0
UPGRADE_TO_2_0
+4
-0
ClassExporter.php
lib/Doctrine/ORM/Export/ClassExporter.php
+22
-5
AllTests.php
tests/Doctrine/Tests/ORM/AllTests.php
+2
-1
No files found.
UPGRADE_TO_2_0
0 → 100644
View file @
45079a1e
Upgrade to Doctrine 2.0
#######################
More information coming soon...
lib/Doctrine/ORM/Export/ClassExporter.php
View file @
45079a1e
...
...
@@ -58,12 +58,27 @@ class ClassExporter
}
/**
* Exports
entity classes to a database, according to the specified mappings.
* Exports
an array of class meta data instances to your database
*
* @param array $classes
*/
public
function
exportClasses
(
array
$classes
)
{
$exportClassesSql
=
$this
->
getExportClassesSql
(
$classes
);
foreach
(
$exportClassesSql
as
$sql
)
{
$this
->
_em
->
getConnection
()
->
execute
(
$sql
);
}
}
/**
* Get an array of sql statements for the specified array of class meta data instances
*
* @param array $classes
* @return array $sql
*/
public
function
getExportClassesSql
(
array
$classes
)
{
$sql
=
array
();
$foreignKeyConstraints
=
array
();
// First we create the tables
...
...
@@ -143,18 +158,20 @@ class ClassExporter
}
$foreignKeyConstraints
[]
=
$constraint2
;
$
this
->
_sm
->
createTable
(
$joinTable
[
'name'
],
$joinTableColumns
,
array
(
));
$
sql
=
array_merge
(
$sql
,
$this
->
_platform
->
getCreateTableSql
(
$joinTable
[
'name'
],
$joinTableColumns
,
array
()
));
}
}
$
this
->
_sm
->
createTable
(
$class
->
getTableName
(),
$columns
,
$options
);
$
sql
=
array_merge
(
$sql
,
$this
->
_platform
->
getCreateTableSql
(
$class
->
getTableName
(),
$columns
,
$options
)
);
}
// Now create the foreign key constraints
if
(
$this
->
_platform
->
supportsForeignKeyConstraints
())
{
foreach
(
$foreignKeyConstraints
as
$fkConstraint
)
{
$
this
->
_sm
->
createForeignKey
(
$fkConstraint
[
'tableName'
],
$fkConstraint
);
$
sql
=
array_merge
(
$sql
,
$this
->
_platform
->
getCreateForeignKeySql
(
$fkConstraint
[
'tableName'
],
$fkConstraint
)
);
}
}
return
$sql
;
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/AllTests.php
View file @
45079a1e
...
...
@@ -32,10 +32,11 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\EntityManagerTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\EntityPersisterTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\CommitOrderCalculatorTest'
);
$suite
->
addTest
(
Query\AllTests
::
suite
());
$suite
->
addTest
(
Hydration\AllTests
::
suite
());
$suite
->
addTest
(
Entity\AllTests
::
suite
());
$suite
->
addTest
(
Export\AllTests
::
suite
());
$suite
->
addTest
(
Associations\AllTests
::
suite
());
$suite
->
addTest
(
Mapping\AllTests
::
suite
());
$suite
->
addTest
(
Functional\AllTests
::
suite
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment