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
89a36ca9
Commit
89a36ca9
authored
Feb 11, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
63de17fe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
36 deletions
+110
-36
Export.php
lib/Doctrine/Export.php
+74
-36
Mysql.php
lib/Doctrine/Export/Mysql.php
+27
-0
Oracle.php
lib/Doctrine/Export/Oracle.php
+9
-0
No files found.
lib/Doctrine/Export.php
View file @
89a36ca9
...
...
@@ -494,22 +494,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
public
function
getDeclaration
(
$name
,
array
$field
)
{
$default
=
''
;
if
(
isset
(
$field
[
'default'
]))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
$this
->
valid_default_values
[
$field
[
'type'
]];
if
(
$field
[
'default'
]
===
''
&&
(
$conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_EMPTY_TO_NULL
)
)
{
$field
[
'default'
]
=
' '
;
}
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
elseif
(
empty
(
$field
[
'notnull'
]))
{
//$default = ' DEFAULT NULL';
}
$default
=
$this
->
getDefaultFieldDeclaration
(
$field
);
$charset
=
(
isset
(
$field
[
'charset'
])
&&
$field
[
'charset'
])
?
' '
.
$this
->
getCharsetFieldDeclaration
(
$field
[
'charset'
])
:
''
;
...
...
@@ -531,6 +516,33 @@ class Doctrine_Export extends Doctrine_Connection_Module
}
return
$this
->
conn
->
quoteIdentifier
(
$name
,
true
)
.
' '
.
$dec
.
$charset
.
$default
.
$notnull
.
$unique
.
$collation
;
}
/**
* getDefaultDeclaration
* Obtain DBMS specific SQL code portion needed to set a default value
* declaration to be used in statements like CREATE TABLE.
*
* @param array $field field definition array
* @return string DBMS specific SQL code portion needed to set a default value
*/
public
function
getDefaultFieldDeclaration
(
$field
)
{
$default
=
''
;
if
(
isset
(
$field
[
'default'
]))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
$this
->
valid_default_values
[
$field
[
'type'
]];
if
(
$field
[
'default'
]
===
''
&&
(
$conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_EMPTY_TO_NULL
)
)
{
$field
[
'default'
]
=
' '
;
}
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
return
$default
;
}
/**
* Obtain DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
...
...
@@ -598,6 +610,8 @@ class Doctrine_Export extends Doctrine_Connection_Module
*
* onUpdate referential update action
*
* deferred deferred constraint checking
*
* The onDelete and onUpdate keys accept the following values:
*
* CASCADE: Delete or update the row from the parent table and automatically delete or
...
...
@@ -621,6 +635,48 @@ class Doctrine_Export extends Doctrine_Connection_Module
* of a field declaration.
*/
public
function
getForeignKeyDeclaration
(
$definition
)
{
$sql
=
$this
->
getForeignKeyBaseDeclaration
();
if
(
isset
(
$definition
[
'deferred'
]))
{
$sql
.=
' '
.
$this
->
getForeignKeyDeferredDeclaration
();
}
$a
=
array
(
'onUpdate'
,
'onDelete'
);
foreach
(
$a
as
$v
)
{
$keyword
=
(
$v
==
'onUpdate'
)
?
' ON UPDATE '
:
' ON DELETE '
;
if
(
isset
(
$definition
[
$v
]))
{
switch
(
$definition
[
$v
])
{
case
'CASCADE'
:
case
'SET NULL'
:
case
'NO ACTION'
:
case
'RESTRICT'
:
case
'SET DEFAULT'
:
$sql
.=
$keyword
.
$definition
[
$v
];
break
;
default
:
throw
new
Doctrine_Export_Exception
(
'Unknown foreign key referential action option given.'
);
}
}
}
return
$sql
;
}
/**
* getForeignKeyDeferredDeclaration
*
* @return string
*/
public
function
getForeignKeyDeferredDeclaration
(
$deferred
)
{
return
''
;
}
/**
* getForeignKeyBaseDeclaration
*
* @return string
*/
public
function
getForeignKeyBaseDeclaration
()
{
$sql
=
''
;
if
(
isset
(
$definition
[
'name'
]))
{
...
...
@@ -647,24 +703,6 @@ class Doctrine_Export extends Doctrine_Connection_Module
.
$definition
[
'foreignTable'
]
.
'('
.
implode
(
', '
,
array_map
(
array
(
$this
->
conn
,
'quoteIdentifier'
),
$definition
[
'foreign'
]))
.
')'
;
$a
=
array
(
'onUpdate'
,
'onDelete'
);
foreach
(
$a
as
$v
)
{
$keyword
=
(
$v
==
'onUpdate'
)
?
' ON UPDATE '
:
' ON DELETE '
;
if
(
isset
(
$definition
[
$v
]))
{
switch
(
$definition
[
$v
])
{
case
'CASCADE'
:
case
'SET NULL'
:
case
'NO ACTION'
:
case
'RESTRICT'
:
case
'SET DEFAULT'
:
$sql
.=
$keyword
.
$definition
[
$v
];
break
;
default
:
throw
new
Doctrine_Export_Exception
(
'Unknown foreign key referential action option given.'
);
}
}
}
return
$sql
;
}
/**
...
...
lib/Doctrine/Export/Mysql.php
View file @
89a36ca9
...
...
@@ -412,6 +412,33 @@ class Doctrine_Export_Mysql extends Doctrine_Export
return
$query
;
}
/**
* getDefaultDeclaration
* Obtain DBMS specific SQL code portion needed to set a default value
* declaration to be used in statements like CREATE TABLE.
*
* @param array $field field definition array
* @return string DBMS specific SQL code portion needed to set a default value
*/
public
function
getDefaultFieldDeclaration
(
$field
)
{
$default
=
''
;
if
(
isset
(
$field
[
'default'
])
&&
$field
[
'length'
]
<=
255
)
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
$this
->
valid_default_values
[
$field
[
'type'
]];
if
(
$field
[
'default'
]
===
''
&&
(
$conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_EMPTY_TO_NULL
)
)
{
$field
[
'default'
]
=
' '
;
}
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
return
$default
;
}
/**
* Obtain DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
...
...
lib/Doctrine/Export/Oracle.php
View file @
89a36ca9
...
...
@@ -380,6 +380,15 @@ END;
$result
=
$this
->
conn
->
exec
(
"ALTER TABLE
$name
RENAME TO "
.
$change_name
);
}
}
/**
* getForeignKeyDeferredDeclaration
*
* @return string
*/
public
function
getForeignKeyDeferredDeclaration
(
$deferred
)
{
return
(
$deferred
)
?
'INITIALLY DEFERRED DEFERRABLE'
:
''
;
}
/**
* create sequence
*
...
...
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