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
fef5d32d
Commit
fef5d32d
authored
Sep 19, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating Export code to use the new methods in Doctrine instead of rewriting same code.
parent
ee1d1a7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
47 deletions
+8
-47
Export.php
lib/Doctrine/Export.php
+8
-47
No files found.
lib/Doctrine/Export.php
View file @
fef5d32d
...
...
@@ -1033,37 +1033,11 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/
public
function
exportClassesSql
(
array
$classes
)
{
$
parent
=
new
ReflectionClass
(
'Doctrine_Record'
);
$
models
=
Doctrine
::
getLoadedModels
(
$classes
);
$sql
=
array
();
$fks
=
array
();
// we iterate trhough the diff of previously declared classes
// and currently declared classes
foreach
(
$classes
as
$name
)
{
$class
=
new
ReflectionClass
(
$name
);
$conn
=
Doctrine_Manager
::
getInstance
()
->
getConnectionForComponent
(
$name
);
// check if class is an instance of Doctrine_Record and not abstract
// class must have method setTableDefinition (to avoid non-Record subclasses like symfony's sfDoctrineRecord)
// we have to recursively iterate through the class parents just to be sure that the classes using for example
// column aggregation inheritance are properly exported to database
while
(
$class
->
isAbstract
()
||
!
$class
->
isSubclassOf
(
$parent
)
||
!
$class
->
hasMethod
(
'setTableDefinition'
)
||
(
$class
->
hasMethod
(
'setTableDefinition'
)
&&
$class
->
getMethod
(
'setTableDefinition'
)
->
getDeclaringClass
()
->
getName
()
!==
$class
->
getName
()))
{
$class
=
$class
->
getParentClass
();
if
(
$class
===
false
)
{
break
;
}
}
if
(
$class
===
false
)
{
continue
;
}
foreach
(
$models
as
$name
)
{
$record
=
new
$name
();
$table
=
$record
->
getTable
();
...
...
@@ -1080,7 +1054,9 @@ class Doctrine_Export extends Doctrine_Connection_Module
$sql
=
array_merge
(
$sql
,
$this
->
exportPluginsSql
(
$table
));
}
}
$sql
=
array_unique
(
$sql
);
rsort
(
$sql
);
return
$sql
;
...
...
@@ -1131,24 +1107,9 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/
public
function
exportSql
(
$directory
=
null
)
{
$declared
=
get_declared_classes
();
if
(
$directory
!==
null
)
{
foreach
((
array
)
$directory
as
$dir
)
{
$it
=
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$dir
),
RecursiveIteratorIterator
::
LEAVES_ONLY
);
foreach
(
$it
as
$file
)
{
$e
=
explode
(
'.'
,
$file
->
getFileName
());
if
(
end
(
$e
)
===
'php'
&&
strpos
(
$file
->
getFileName
(),
'.inc'
)
===
false
)
{
require_once
$file
->
getPathName
();
}
}
}
$declared
=
array_diff
(
get_declared_classes
(),
$declared
);
}
$models
=
Doctrine
::
loadModels
(
$directory
);
return
$this
->
exportClassesSql
(
$
declared
);
return
$this
->
exportClassesSql
(
$
models
);
}
/**
* exportTable
...
...
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