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
Show 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,42 +686,54 @@ class Doctrine_Export extends Doctrine_Connection_Module
...
@@ -680,42 +686,54 @@ 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'
]))
{
return
$sql
;
$sql
.=
' '
.
$this
->
getForeignKeyDeferredDeclaration
();
}
}
/**
$a
=
array
(
'onUpdate'
,
'onDelete'
);
* getAdvancedForeignKeyOptions
foreach
(
$a
as
$v
)
{
* Return the FOREIGN KEY query section dealing with non-standard options
$keyword
=
(
$v
==
'onUpdate'
)
?
' ON UPDATE '
:
' ON DELETE '
;
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
*
if
(
isset
(
$definition
[
$v
]))
{
* @param array $definition foreign key definition
$upper
=
strtoupper
(
$definition
[
$v
]);
* @return string
*/
public
function
getAdvancedForeignKeyOptions
(
$definition
)
{
$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
)
{
switch
(
$upper
)
{
case
'CASCADE'
:
case
'CASCADE'
:
case
'SET NULL'
:
case
'SET NULL'
:
case
'NO ACTION'
:
case
'NO ACTION'
:
case
'RESTRICT'
:
case
'RESTRICT'
:
case
'SET DEFAULT'
:
case
'SET DEFAULT'
:
$sql
.=
$keyword
.
$upper
;
return
$upper
;
break
;
break
;
default
:
default
:
throw
new
Doctrine_Export_Exception
(
'Unknown foreign key referential action \''
.
$upper
.
'\' given.'
);
throw
new
Doctrine_Export_Exception
(
'Unknown foreign key referential action \''
.
$upper
.
'\' given.'
);
}
}
}
}
}
return
$sql
;
}
/**
* getForeignKeyDeferredDeclaration
*
* @return string
*/
public
function
getForeignKeyDeferredDeclaration
(
$deferred
)
{
return
''
;
}
/**
/**
* getForeignKeyBaseDeclaration
* getForeignKeyBaseDeclaration
* Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
* Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
...
...
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