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
0e964840
Commit
0e964840
authored
Sep 20, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to make export schema yml closer to working :)
parent
8402633b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
113 additions
and
46 deletions
+113
-46
Doctrine.php
lib/Doctrine.php
+1
-0
Parser.php
lib/Doctrine/Parser.php
+49
-23
Yml.php
lib/Doctrine/Parser/Yml.php
+19
-1
GroupUser.php
models/GroupUser.php
+6
-0
Phonenumber.php
models/Phonenumber.php
+8
-0
index.php
playground/index.php
+8
-1
models.php
playground/models.php
+22
-21
No files found.
lib/Doctrine.php
View file @
0e964840
...
...
@@ -477,6 +477,7 @@ final class Doctrine
}
$parent
=
new
ReflectionClass
(
'Doctrine_Record'
);
$loadedModels
=
array
();
// we iterate trhough the diff of previously declared classes
...
...
lib/Doctrine/Parser.php
View file @
0e964840
...
...
@@ -31,47 +31,73 @@
*/
abstract
class
Doctrine_Parser
{
/**
* loadData
*
* Override in the parser driver
*
* @param string $array
* @return void
* @author Jonathan H. Wage
*/
abstract
public
function
loadData
(
$array
);
/**
* dumpData
*
* Override in the praser driver
*
* @param string $array
* @param string $path
* @return void
* @author Jonathan H. Wage
*/
abstract
public
function
dumpData
(
$array
,
$path
=
null
);
/**
* getParser
*
* Get instance of the specified parser
*
* @param string $type
* @return void
* @author Jonathan H. Wage
*/
static
public
function
getParser
(
$type
)
{
$class
=
'Doctrine_Parser_'
.
ucfirst
(
$type
);
return
new
$class
;
}
/**
* load
*
* Interface for loading and parsing data from a file
*
* @param string $path
* @param string $type
* @return void
* @author Jonathan H. Wage
*/
static
public
function
load
(
$path
,
$type
=
'xml'
)
{
$parser
=
self
::
getParser
(
$type
);
return
$parser
->
loadData
(
$path
);
}
/**
* dump
*
* Interface for pulling and dumping data to a file
*
* @param string $array
* @param string $path
* @param string $type
* @return void
* @author Jonathan H. Wage
*/
static
public
function
dump
(
$array
,
$path
=
null
,
$type
=
'xml'
)
{
$parser
=
self
::
getParser
(
$type
);
return
$parser
->
dumpData
(
$array
,
$path
);
}
static
public
function
loadXml
(
$path
)
{
return
self
::
load
(
$path
,
'xml'
);
}
static
public
function
dumpXml
(
$array
,
$path
=
null
)
{
return
self
::
dump
(
$array
,
$path
,
'xml'
);
}
static
public
function
loadYml
(
$path
)
{
return
self
::
load
(
$path
,
'yml'
);
}
static
public
function
dumpYml
(
$array
,
$path
=
null
)
{
return
self
::
dump
(
$array
,
$path
,
'yml'
);
}
}
\ No newline at end of file
lib/Doctrine/Parser/Yml.php
View file @
0e964840
...
...
@@ -33,6 +33,16 @@ require_once('spyc.php');
*/
class
Doctrine_Parser_Yml
extends
Doctrine_Parser
{
/**
* dumpData
*
* Dump an array of data to a specified path to yml file
*
* @param string $array
* @param string $path
* @return void
* @author Jonathan H. Wage
*/
public
function
dumpData
(
$array
,
$path
=
null
)
{
$spyc
=
new
Spyc
();
...
...
@@ -45,7 +55,15 @@ class Doctrine_Parser_Yml extends Doctrine_Parser
return
$yml
;
}
}
/**
* loadData
*
* Load and parse data from a yml file
*
* @param string $path
* @return void
* @author Jonathan H. Wage
*/
public
function
loadData
(
$path
)
{
$spyc
=
new
Spyc
();
...
...
models/GroupUser.php
View file @
0e964840
...
...
@@ -7,4 +7,10 @@ class Groupuser extends Doctrine_Record
$this
->
hasColumn
(
'group_id'
,
'integer'
);
$this
->
hasColumn
(
'user_id'
,
'integer'
);
}
public
function
setUp
()
{
$this
->
hasOne
(
'Group'
,
array
(
'local'
=>
'group_id'
,
'foreign'
=>
'id'
));
$this
->
hasOne
(
'User'
,
array
(
'local'
=>
'user_id'
,
'foreign'
=>
'id'
));
}
}
models/Phonenumber.php
View file @
0e964840
...
...
@@ -11,5 +11,13 @@ class Phonenumber extends Doctrine_Record
$this
->
hasOne
(
'Entity'
,
array
(
'local'
=>
'entity_id'
,
'foreign'
=>
'id'
,
'onDelete'
=>
'CASCADE'
));
$this
->
hasOne
(
'Group'
,
array
(
'local'
=>
'entity_id'
,
'foreign'
=>
'id'
,
'onDelete'
=>
'CASCADE'
));
$this
->
hasOne
(
'User'
,
array
(
'local'
=>
'entity_id'
,
'foreign'
=>
'id'
,
'onDelete'
=>
'CASCADE'
));
}
}
playground/index.php
View file @
0e964840
<?php
require_once
(
'playground.php'
);
require_once
(
'connection.php'
);
require_once
(
'models.php'
);
\ No newline at end of file
require_once
(
'models.php'
);
require_once
(
'data.php'
);
Doctrine_Data
::
exportData
(
'data/data.yml'
,
'yml'
,
$tables
);
//Doctrine_Data::importData('data/data.yml', 'yml', $tables);
//Doctrine_Data::exportData('data/test.yml', 'yml', $tables);
\ No newline at end of file
playground/models.php
View file @
0e964840
<?php
Doctrine
::
loadModels
(
'models'
);
$models
=
Doctrine
::
loadModels
(
'models'
);
$manager
->
setAttribute
(
Doctrine
::
ATTR_EXPORT
,
Doctrine
::
EXPORT_ALL
);
$tables
=
array
(
'entity'
,
'entityReference'
,
'email'
,
'phonenumber'
,
'groupuser'
,
'album'
,
'song'
,
'element'
,
'error'
,
'description'
,
'address'
,
'account'
,
'task'
,
'resource'
,
'assignment'
,
'resourceType'
,
'resourceReference'
);
$tables
=
array
(
'Entity'
,
'EntityReference'
,
'EntityAddress'
,
'Email'
,
'Phonenumber'
,
'Groupuser'
,
'Group'
,
'User'
,
'Album'
,
'Song'
,
'Element'
,
'Error'
,
'Description'
,
'Address'
,
'Account'
,
'Task'
,
'Resource'
,
'Assignment'
,
'ResourceType'
,
'ResourceReference'
);
$conn
->
export
->
exportClasses
(
$tables
);
require_once
(
'data.php'
);
\ No newline at end of file
$conn
->
export
->
exportClasses
(
$tables
);
\ 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