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
e9d7274f
Commit
e9d7274f
authored
Feb 10, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated import builder
parent
8703d6e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
25 deletions
+23
-25
Builder.php
lib/Doctrine/Import/Builder.php
+23
-25
No files found.
lib/Doctrine/Import/Builder.php
View file @
e9d7274f
...
...
@@ -35,7 +35,9 @@
*/
class
Doctrine_Import_Builder
{
/**
* @var string $path the path where imported files are being generated
*/
private
$path
=
''
;
private
$suffix
=
'.php'
;
...
...
@@ -54,10 +56,10 @@ class Doctrine_Import_Builder
}
/**
* setTargetPath
*
* @param string path
* @param string path
the path where imported files are being generated
* @return
* @access public
*/
public
function
setTargetPath
(
$path
)
{
...
...
@@ -67,26 +69,17 @@ class Doctrine_Import_Builder
$this
->
path
=
$path
;
}
public
function
getTargetPath
()
{
return
$this
->
path
;
}
/**
* getTargetPath
*
* @param string path
* @return
* @access public
* @return string the path where imported files are being generated
*/
public
function
setFileSuffix
(
$suffix
)
{
$this
->
suffix
=
$suffix
;
}
public
function
getFileSuffix
()
public
function
getTargetPath
()
{
return
$this
->
suffix
;
return
$this
->
path
;
}
public
function
buildRecord
(
Doctrine_Schema_Table
$table
)
public
function
buildRecord
(
$table
,
$tableColumns
)
{
if
(
empty
(
$this
->
path
))
{
throw
new
Doctrine_Import_Builder_Exception
(
'No build target directory set.'
);
...
...
@@ -95,14 +88,13 @@ class Doctrine_Import_Builder
throw
new
Doctrine_Import_Builder_Exception
(
'Build target directory '
.
$this
->
path
.
' is not writable.'
);
}
$created
=
date
(
'l dS \of F Y h:i:s A'
);
$className
=
Doctrine
::
classify
(
$table
->
get
(
'name'
)
);
$className
=
Doctrine
::
classify
(
$table
);
$fileName
=
$this
->
path
.
DIRECTORY_SEPARATOR
.
$className
.
$this
->
suffix
;
$columns
=
array
();
$i
=
0
;
foreach
(
$table
as
$name
=>
$column
)
{
$columns
[
$i
]
=
' $this->hasColumn(\''
.
$
column
[
'name'
]
.
'\', \''
.
$column
[
'type'
]
.
'\''
;
foreach
(
$table
Columns
as
$name
=>
$column
)
{
$columns
[
$i
]
=
' $this->hasColumn(\''
.
$
name
.
'\', \''
.
$column
[
'ptype'
][
0
]
.
'\''
;
if
(
$column
[
'length'
])
{
$columns
[
$i
]
.=
', '
.
$column
[
'length'
];
}
else
{
...
...
@@ -126,10 +118,15 @@ class Doctrine_Import_Builder
if
(
$column
[
'unique'
])
{
$a
[]
=
'\'unique\' => true'
;
}
if
(
$column
[
'unsigned'
])
{
$a
[]
=
'\'unsigned\' => true'
;
}
if
(
!
empty
(
$a
))
{
$columns
[
$i
]
.=
', '
.
'array('
.
implode
(
',
'
,
$a
)
.
')'
;
$columns
[
$i
]
.=
', '
.
'array('
;
$length
=
strlen
(
$columns
[
$i
]);
$columns
[
$i
]
.=
implode
(
',
'
.
str_repeat
(
' '
,
$length
),
$a
)
.
')'
;
}
$columns
[
$i
]
.=
');'
;
...
...
@@ -140,12 +137,13 @@ class Doctrine_Import_Builder
$i
++
;
}
$content
=
sprintf
(
self
::
$tpl
,
$created
,
$className
,
implode
(
''
,
$columns
));
$content
=
sprintf
(
self
::
$tpl
,
$created
,
$className
,
implode
(
"
\n
"
,
$columns
));
$bytes
=
file_put_contents
(
$fileName
,
$content
);
if
(
$bytes
===
false
)
if
(
$bytes
===
false
)
{
throw
new
Doctrine_Import_Builder_Exception
(
"Couldn't write file "
.
$fileName
);
}
}
/**
*
...
...
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