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
fe34a0d2
Commit
fe34a0d2
authored
Oct 08, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to fixtures importing and relationships satisfying.
parent
c69c0c5d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
3 deletions
+37
-3
Import.php
lib/Doctrine/Data/Import.php
+6
-1
Export.php
lib/Doctrine/Export.php
+20
-1
Schema.php
lib/Doctrine/Import/Schema.php
+1
-1
index.php
playground/index.php
+10
-0
No files found.
lib/Doctrine/Data/Import.php
View file @
fe34a0d2
...
...
@@ -127,6 +127,7 @@ class Doctrine_Data_Import extends Doctrine_Data
}
}
// Satisfy all relationships
foreach
(
$pendingRelations
as
$rowKey
=>
$pending
)
{
$obj
=
$pending
[
'obj'
];
$key
=
$pending
[
'key'
];
...
...
@@ -134,7 +135,11 @@ class Doctrine_Data_Import extends Doctrine_Data
$foreign
=
$pending
[
'foreign'
];
$pks
=
$primaryKeys
[
$key
];
$obj
->
$local
=
$pks
[
'id'
];
}
// Loop over all again to save them since we satisfied all pending relationships above
foreach
(
$pendingRelations
as
$rowKey
=>
$pending
)
{
$obj
=
$pending
[
'obj'
];
$obj
->
save
();
}
}
...
...
lib/Doctrine/Export.php
View file @
fe34a0d2
...
...
@@ -1000,12 +1000,30 @@ class Doctrine_Export extends Doctrine_Connection_Module
if
(
!
isset
(
$connections
[
$connectionName
]))
{
$connections
[
$connectionName
]
=
array
();
$connections
[
$connectionName
][
'creates'
]
=
array
();
$connections
[
$connectionName
][
'alters'
]
=
array
();
}
$connections
[
$connectionName
]
=
array_merge
(
$connections
[
$connectionName
],
$this
->
exportClassesSql
(
array
(
$class
)));
$sql
=
$this
->
exportClassesSql
(
array
(
$class
));
// The create sql query is the first one, and everything else is the alters
$create
=
$sql
[
0
];
// Remove create from the main array
unset
(
$sql
[
0
]);
// Store the creates and alters individually so we can merge them back together later
// We need the creates to happen first, then the alters
$connections
[
$connectionName
][
'creates'
][]
=
$create
;
$connections
[
$connectionName
][
'alters'
]
=
array_merge
(
$connections
[
$connectionName
][
'alters'
],
$sql
);
}
// Loop over all the sql again to merge the creates and alters in to the same array, but so that the alters are at the bottom
$build
=
array
();
foreach
(
$connections
as
$connectionName
=>
$sql
)
{
$build
[
$connectionName
]
=
array_merge
(
$sql
[
'creates'
],
$sql
[
'alters'
]);
}
foreach
(
$build
as
$connectionName
=>
$sql
)
{
$connection
=
Doctrine_Manager
::
getInstance
()
->
getConnection
(
$connectionName
);
$connection
->
beginTransaction
();
...
...
@@ -1016,6 +1034,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
}
catch
(
Doctrine_Connection_Exception
$e
)
{
// we only want to silence table already exists errors
if
(
$e
->
getPortableCode
()
!==
Doctrine
::
ERR_ALREADY_EXISTS
)
{
echo
$query
.
"
\n
"
;
$connection
->
rollback
();
throw
$e
;
}
...
...
lib/Doctrine/Import/Schema.php
View file @
fe34a0d2
...
...
@@ -138,7 +138,7 @@ class Doctrine_Import_Schema
$columns
=
array
();
$className
=
isset
(
$table
[
'className'
])
?
(
string
)
$table
[
'className'
]
:
(
string
)
$className
;
$tableName
=
isset
(
$table
[
'tableName'
])
?
(
string
)
$table
[
'tableName'
]
:
(
string
)
$className
;
$tableName
=
isset
(
$table
[
'tableName'
])
?
(
string
)
$table
[
'tableName'
]
:
(
string
)
Doctrine
::
tableize
(
$className
)
;
$build
[
$className
][
'className'
]
=
$className
;
...
...
playground/index.php
View file @
fe34a0d2
...
...
@@ -6,7 +6,17 @@ $conn = Doctrine_Manager::connection($dbh);
$manager
=
Doctrine_Manager
::
getInstance
();
$manager
->
setAttribute
(
Doctrine
::
ATTR_EXPORT
,
Doctrine
::
EXPORT_ALL
);
// Build models from schema
//$import = new Doctrine_Import_Schema();
//$import->generateBaseClasses(true);
//$import->importSchema('schema.yml', 'yml', 'test_models');
// Export models schema to database
//Doctrine::exportSchema('test_models');
// Load model classes
Doctrine
::
loadModels
(
'test_models'
);
// Load data fixtures
$data
=
new
Doctrine_Data
();
$data
->
importData
(
'fixtures.yml'
);
\ No newline at end of file
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