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
b1c4c5f5
Commit
b1c4c5f5
authored
Nov 10, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged r3122:r3126
parent
ec1ec994
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
28 deletions
+75
-28
Doctrine.php
lib/Doctrine.php
+43
-3
Import.php
lib/Doctrine/Data/Import.php
+10
-10
Builder.php
lib/Doctrine/Import/Builder.php
+12
-4
Schema.php
lib/Doctrine/Import/Schema.php
+10
-11
No files found.
lib/Doctrine.php
View file @
b1c4c5f5
...
...
@@ -714,6 +714,8 @@ final class Doctrine
$manager
=
Doctrine_Manager
::
getInstance
();
$connections
=
$manager
->
getConnections
();
$results
=
array
();
foreach
(
$connections
as
$name
=>
$connection
)
{
if
(
!
empty
(
$specifiedConnections
)
&&
!
in_array
(
$name
,
$specifiedConnections
))
{
continue
;
...
...
@@ -738,10 +740,14 @@ final class Doctrine
// Reopen original connection with newly created database
$manager
->
openConnection
(
new
PDO
(
$info
[
'dsn'
],
$username
,
$password
),
$name
,
true
);
}
catch
(
Exception
$e
)
{
$results
[
$name
]
=
true
;
}
catch
(
Exception
$e
)
{
$results
[
$name
]
=
false
;
}
}
return
$results
;
}
/**
...
...
@@ -762,6 +768,8 @@ final class Doctrine
$connections
=
$manager
->
getConnections
();
$results
=
array
();
foreach
(
$connections
as
$name
=>
$connection
)
{
if
(
!
empty
(
$specifiedConnections
)
&&
!
in_array
(
$name
,
$specifiedConnections
))
{
continue
;
...
...
@@ -769,10 +777,14 @@ final class Doctrine
try
{
$connection
->
export
->
dropDatabase
(
$name
);
}
catch
(
Exception
$e
)
{
$results
[
$name
]
=
true
;
}
catch
(
Exception
$e
)
{
$results
[
$name
]
=
false
;
}
}
return
$results
;
}
/**
...
...
@@ -1047,10 +1059,38 @@ final class Doctrine
*/
public
static
function
makeDirectories
(
$path
,
$mode
=
0777
)
{
if
(
!
$path
)
{
return
false
;
}
if
(
is_dir
(
$path
)
||
is_file
(
$path
))
{
return
true
;
}
return
mkdir
(
$path
,
$mode
,
true
);
}
}
function
removeDirectories
(
$folderPath
)
{
if
(
is_dir
(
$folderPath
))
{
foreach
(
scandir
(
$folderPath
)
as
$value
)
{
if
(
$value
!=
'.'
&&
$value
!=
'..'
)
{
$value
=
$folderPath
.
"/"
.
$value
;
if
(
is_dir
(
$value
))
{
self
::
removeDirectories
(
$value
);
}
else
if
(
is_file
(
$value
))
{
@
unlink
(
$value
);
}
}
}
return
rmdir
(
$folderPath
);
}
else
{
return
false
;
}
}
}
\ No newline at end of file
lib/Doctrine/Data/Import.php
View file @
b1c4c5f5
...
...
@@ -64,7 +64,7 @@ class Doctrine_Data_Import extends Doctrine_Data
// If they specified a specific yml file
if
(
end
(
$e
)
==
'yml'
)
{
$array
=
array_merge
(
Doctrine_Parser
::
load
(
$dir
,
$this
->
getFormat
()),
$array
);
$array
=
array_merge
(
$array
,
Doctrine_Parser
::
load
(
$dir
,
$this
->
getFormat
())
);
// If they specified a directory
}
else
if
(
is_dir
(
$dir
))
{
$it
=
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$dir
),
...
...
@@ -73,17 +73,17 @@ class Doctrine_Data_Import extends Doctrine_Data
foreach
(
$it
as
$file
)
{
$e
=
explode
(
'.'
,
$file
->
getFileName
());
if
(
in_array
(
end
(
$e
),
$this
->
getFormats
()))
{
$array
=
array_merge
(
Doctrine_Parser
::
load
(
$file
->
getPathName
(),
$this
->
getFormat
()),
$array
);
$array
=
array_merge
(
$array
,
Doctrine_Parser
::
load
(
$file
->
getPathName
(),
$this
->
getFormat
())
);
}
}
}
}
}
$this
->
loadData
(
$array
);
$this
->
_
loadData
(
$array
);
}
protected
function
buildRows
(
$className
,
$data
)
protected
function
_
buildRows
(
$className
,
$data
)
{
$rows
=
array
();
foreach
(
$data
as
$rowKey
=>
$row
)
{
...
...
@@ -96,7 +96,7 @@ class Doctrine_Data_Import extends Doctrine_Data
// Skip associative arrays defining keys to relationships
if
(
!
isset
(
$keys
[
0
]))
{
$rows
=
array_merge
(
$rows
,
$this
->
buildRows
(
Doctrine
::
getTable
(
$className
)
->
getRelation
(
$key
)
->
getTable
()
->
getOption
(
'name'
),
$value
));
$rows
=
array_merge
(
$rows
,
$this
->
_
buildRows
(
Doctrine
::
getTable
(
$className
)
->
getRelation
(
$key
)
->
getTable
()
->
getOption
(
'name'
),
$value
));
}
}
}
...
...
@@ -110,7 +110,7 @@ class Doctrine_Data_Import extends Doctrine_Data
* @param string $array
* @return void
*/
protected
function
loadData
(
array
$array
)
protected
function
_
loadData
(
array
$array
)
{
$specifiedModels
=
$this
->
getModels
();
$rows
=
array
();
...
...
@@ -127,9 +127,9 @@ class Doctrine_Data_Import extends Doctrine_Data
$templates
=
array_keys
(
$obj
->
getTable
()
->
getTemplates
());
if
(
in_array
(
'Doctrine_Template_NestedSet'
,
$templates
))
{
$this
->
loadNestedSetData
(
$className
,
$data
);
$this
->
_
loadNestedSetData
(
$className
,
$data
);
}
else
{
$rows
=
array_merge
(
$rows
,
$this
->
buildRows
(
$className
,
$data
));
$rows
=
array_merge
(
$rows
,
$this
->
_
buildRows
(
$className
,
$data
));
}
}
...
...
@@ -189,7 +189,7 @@ class Doctrine_Data_Import extends Doctrine_Data
}
}
protected
function
loadNestedSetData
(
$model
,
$nestedSetData
,
$parent
=
null
)
protected
function
_
loadNestedSetData
(
$model
,
$nestedSetData
,
$parent
=
null
)
{
$manager
=
Doctrine_Manager
::
getInstance
();
...
...
@@ -222,7 +222,7 @@ class Doctrine_Data_Import extends Doctrine_Data
if
(
is_array
(
$children
)
AND
!
empty
(
$children
)
)
{
$this
->
loadNestedSetData
(
$model
,
$children
,
$record
);
$this
->
_
loadNestedSetData
(
$model
,
$children
,
$record
);
}
}
}
...
...
lib/Doctrine/Import/Builder.php
View file @
b1c4c5f5
...
...
@@ -131,8 +131,8 @@ class Doctrine_Import_Builder
{
Doctrine
::
makeDirectories
(
$path
);
if
(
!
$this
->
_packagesPath
)
{
$this
->
_packagesPath
=
$path
.
DIRECTORY_SEPARATOR
.
'packages'
;
if
(
!
$this
->
_packagesPath
)
{
$this
->
setPackagesPath
(
$path
.
DIRECTORY_SEPARATOR
.
'packages'
)
;
}
$this
->
_path
=
$path
;
...
...
@@ -157,6 +157,8 @@ class Doctrine_Import_Builder
*/
public
function
setPackagesPath
(
$packagesPath
)
{
Doctrine
::
makeDirectories
(
$packagesPath
);
$this
->
_packagesPath
=
$packagesPath
;
}
...
...
@@ -259,8 +261,14 @@ class Doctrine_Import_Builder
*/
public
function
setOption
(
$key
,
$value
)
{
$name
=
'_'
.
$key
;
$this
->
$name
=
$value
;
$name
=
'set'
.
Doctrine
::
classify
(
$key
);
if
(
method_exists
(
$this
,
$name
))
{
$this
->
$name
(
$value
);
}
else
{
$key
=
'_'
.
$key
;
$this
->
$key
=
$value
;
}
}
/**
...
...
lib/Doctrine/Import/Schema.php
View file @
b1c4c5f5
...
...
@@ -117,7 +117,7 @@ class Doctrine_Import_Schema
}
}
$this
->
buildRelationships
(
$array
);
$this
->
_
buildRelationships
(
$array
);
return
array
(
'schema'
=>
$array
,
'relations'
=>
$this
->
_relations
);
}
...
...
@@ -137,13 +137,12 @@ class Doctrine_Import_Schema
{
$builder
=
new
Doctrine_Import_Builder
();
$builder
->
setTargetPath
(
$directory
);
$builder
->
generateBaseClasses
(
$this
->
getOption
(
'generateBaseClasses'
));
$builder
->
generateTableClasses
(
$this
->
getOption
(
'generateTableClasses'
));
$builder
->
setBaseClassesDirectory
(
$this
->
getOption
(
'baseClassesDirectory'
));
$builder
->
setBaseClassName
(
$this
->
getOption
(
'baseClassName'
));
$builder
->
setPackagesPath
(
$this
->
getOption
(
'packagesPath'
));
$builder
->
setPackagesPrefix
(
$this
->
getOption
(
'packagesPrefix'
));
$builder
->
setSuffix
(
$this
->
getOption
(
'suffix'
));
foreach
(
$this
->
_options
as
$key
=>
$value
)
{
if
(
$value
)
{
$builder
->
setOption
(
$key
,
$value
);
}
}
$schema
=
$this
->
buildSchema
(
$schema
,
$format
);
...
...
@@ -376,7 +375,7 @@ class Doctrine_Import_Schema
* @param string $array
* @return void
*/
protected
function
buildRelationships
(
&
$array
)
protected
function
_
buildRelationships
(
&
$array
)
{
foreach
(
$array
as
$name
=>
$properties
)
{
if
(
!
isset
(
$properties
[
'relations'
]))
{
...
...
@@ -420,7 +419,7 @@ class Doctrine_Import_Schema
}
// Now we fix all the relationships and auto-complete opposite ends of relationships
$this
->
fixRelationships
();
$this
->
_
fixRelationships
();
}
/**
...
...
@@ -430,7 +429,7 @@ class Doctrine_Import_Schema
*
* @return void
*/
protected
function
fixRelationships
()
protected
function
_
fixRelationships
()
{
foreach
(
$this
->
_relations
as
$className
=>
$relations
)
{
foreach
(
$relations
AS
$alias
=>
$relation
)
{
...
...
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