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
8d8b66eb
Commit
8d8b66eb
authored
Jun 13, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
porting features from MDB2
parent
365bdc23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
29 deletions
+47
-29
Export.php
lib/Doctrine/Export.php
+47
-29
No files found.
lib/Doctrine/Export.php
View file @
8d8b66eb
...
@@ -198,9 +198,15 @@ class Doctrine_Export extends Doctrine_Connection_Module
...
@@ -198,9 +198,15 @@ class Doctrine_Export extends Doctrine_Connection_Module
*
*
* @param string $seqName name of the sequence to be created
* @param string $seqName name of the sequence to be created
* @param string $start start value of the sequence; default is 1
* @param string $start start value of the sequence; default is 1
* @param array $options An associative array of table options:
* array(
* 'comment' => 'Foo',
* 'charset' => 'utf8',
* 'collate' => 'utf8_unicode_ci',
* );
* @return string
* @return string
*/
*/
public
function
createSequenceSql
(
$seqName
,
$start
=
1
)
public
function
createSequenceSql
(
$seqName
,
$start
=
1
,
array
$options
=
array
()
)
{
{
throw
new
Doctrine_Export_Exception
(
'Create sequence not supported by this driver.'
);
throw
new
Doctrine_Export_Exception
(
'Create sequence not supported by this driver.'
);
}
}
...
@@ -680,41 +686,53 @@ class Doctrine_Export extends Doctrine_Connection_Module
...
@@ -680,41 +686,53 @@ class Doctrine_Export extends Doctrine_Connection_Module
public
function
getForeignKeyDeclaration
(
array
$definition
)
public
function
getForeignKeyDeclaration
(
array
$definition
)
{
{
$sql
=
$this
->
getForeignKeyBaseDeclaration
(
$definition
);
$sql
=
$this
->
getForeignKeyBaseDeclaration
(
$definition
);
$sql
.=
$this
->
getForeignKeyAdvancedOptions
(
$definition
);
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
]))
{
$upper
=
strtoupper
(
$definition
[
$v
]);
switch
(
$upper
)
{
case
'CASCADE'
:
case
'SET NULL'
:
case
'NO ACTION'
:
case
'RESTRICT'
:
case
'SET DEFAULT'
:
$sql
.=
$keyword
.
$upper
;
break
;
default
:
throw
new
Doctrine_Export_Exception
(
'Unknown foreign key referential action \''
.
$upper
.
'\' given.'
);
}
}
}
return
$sql
;
return
$sql
;
}
}
/**
/**
* getForeignKeyDeferredDeclaration
* getAdvancedForeignKeyOptions
* Return the FOREIGN KEY query section dealing with non-standard options
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
*
*
* @param array $definition foreign key definition
* @return string
* @return string
*/
*/
public
function
get
ForeignKeyDeferredDeclaration
(
$deferred
)
public
function
get
AdvancedForeignKeyOptions
(
$definition
)
{
{
return
''
;
$query
=
''
;
if
(
!
empty
(
$definition
[
'onUpdate'
]))
{
$query
.=
' ON UPDATE '
.
$this
->
getForeignKeyRefentialAction
(
$definition
[
'onUpdate'
]);
}
if
(
!
empty
(
$definition
[
'onDelete'
]))
{
$query
.=
' ON DELETE '
.
$this
->
getForeignKeyRefentialAction
(
$definition
[
'onDelete'
]);
}
return
$query
;
}
/**
* getForeignKeyReferentialAction
*
* returns given referential action in uppercase if valid, otherwise throws
* an exception
*
* @throws Doctrine_Exception_Exception if unknown referential action given
* @param string $action foreign key referential action
* @param string foreign key referential action in uppercase
*/
public
function
getForeignKeyReferentialAction
(
$action
)
{
$upper
=
strtoupper
(
$action
);
switch
(
$upper
)
{
case
'CASCADE'
:
case
'SET NULL'
:
case
'NO ACTION'
:
case
'RESTRICT'
:
case
'SET DEFAULT'
:
return
$upper
;
break
;
default
:
throw
new
Doctrine_Export_Exception
(
'Unknown foreign key referential action \''
.
$upper
.
'\' given.'
);
}
}
}
/**
/**
* getForeignKeyBaseDeclaration
* getForeignKeyBaseDeclaration
...
...
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