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
4ff559ce
Commit
4ff559ce
authored
Jan 15, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored import drivers
parent
7e8310ce
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
160 deletions
+33
-160
Mssql.php
lib/Doctrine/Import/Mssql.php
+5
-79
Mysql.php
lib/Doctrine/Import/Mysql.php
+26
-80
Oracle.php
lib/Doctrine/Import/Oracle.php
+2
-1
No files found.
lib/Doctrine/Import/Mssql.php
View file @
4ff559ce
...
...
@@ -33,34 +33,6 @@ Doctrine::autoload('Doctrine_Import');
*/
class
Doctrine_Import_Mssql
extends
Doctrine_Import
{
/**
* lists all databases
*
* @return array
*/
public
function
listDatabases
()
{
}
/**
* lists all availible database functions
*
* @return array
*/
public
function
listFunctions
()
{
}
/**
* lists all database triggers
*
* @param string|null $database
* @return array
*/
public
function
listTriggers
(
$database
=
null
)
{
}
/**
* lists all database sequences
*
...
...
@@ -70,29 +42,9 @@ class Doctrine_Import_Mssql extends Doctrine_Import
public
function
listSequences
(
$database
=
null
)
{
$query
=
"SELECT name FROM sysobjects WHERE xtype = 'U'"
;
$table_names
=
$this
->
conn
->
fetchColumn
(
$query
);
$result
=
array
();
foreach
(
$table_names
as
$table_name
)
{
if
(
$sqn
=
$this
->
_fixSequenceName
(
$table_name
,
true
))
{
$result
[]
=
$sqn
;
}
}
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_map
((
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
}
return
$result
;
}
/**
* lists table constraints
*
* @param string $table database table name
* @return array
*/
public
function
listTableConstraints
(
$table
)
{
$tableNames
=
$this
->
conn
->
fetchColumn
(
$query
);
return
array_map
(
array
(
$this
->
conn
,
'fixSequenceName'
),
$tableNames
);
}
/**
* lists table constraints
...
...
@@ -168,12 +120,6 @@ class Doctrine_Import_Mssql extends Doctrine_Import
$result
=
$this
->
conn
->
fetchColumn
(
$query
);
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
&&
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
)
{
$result
=
array_map
((
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
}
return
$result
;
}
/**
...
...
@@ -204,23 +150,11 @@ class Doctrine_Import_Mssql extends Doctrine_Import
$result
=
array
();
foreach
(
$indexes
as
$index
)
{
if
(
!
in_array
(
$index
,
$pkAll
)
&&
$index
!=
null
)
{
$result
[
$this
->
_fixIndexName
(
$index
)]
=
true
;
$result
[
]
=
$this
->
_fixIndexName
(
$index
)
;
}
}
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_change_key_case
(
$result
,
$this
->
conn
->
options
[
'field_case'
]);
}
return
array_keys
(
$result
);
}
/**
* lists database users
*
* @return array
*/
public
function
listUsers
()
{
return
$result
;
}
/**
* lists database views
...
...
@@ -232,14 +166,6 @@ class Doctrine_Import_Mssql extends Doctrine_Import
{
$query
=
"SELECT name FROM sysobjects WHERE xtype = 'V'"
;
$result
=
$this
->
conn
->
fetchColumn
(
$query
);
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
&&
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
)
{
$result
=
array_map
((
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
}
return
$result
;
return
$this
->
conn
->
fetchColumn
(
$query
);
}
}
lib/Doctrine/Import/Mysql.php
View file @
4ff559ce
...
...
@@ -38,27 +38,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
'listTables'
=>
'SHOW TABLES'
,
'listUsers'
=>
'SELECT DISTINCT USER FROM USER'
,
'listViews'
=>
"SHOW FULL TABLES %sWHERE Table_type = 'VIEW'"
,
);
/**
* lists all availible database functions
*
* @return array
*/
public
function
listFunctions
()
{
}
/**
* lists all database triggers
*
* @param string|null $database
* @return array
*/
public
function
listTriggers
(
$database
=
null
)
{
}
/**
* lists all database sequences
*
...
...
@@ -73,13 +53,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
}
$tableNames
=
$this
->
conn
->
fetchColumn
(
$query
);
$result
=
array
();
foreach
(
$tableNames
as
$tableName
)
{
if
(
$sqn
=
$this
->
_fixSequenceName
(
$tableName
,
true
))
{
$result
[]
=
$sqn
;
}
}
return
$result
;
return
array_map
(
array
(
$this
->
conn
,
'fixSequenceName'
),
$tableNames
);
}
/**
* lists table constraints
...
...
@@ -89,40 +63,36 @@ class Doctrine_Import_Mysql extends Doctrine_Import
*/
public
function
listTableConstraints
(
$table
)
{
$key
_n
ame
=
'Key_name'
;
$non
_u
nique
=
'Non_unique'
;
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$key
N
ame
=
'Key_name'
;
$non
U
nique
=
'Non_unique'
;
if
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
if
(
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
)
{
$key
_name
=
strtolower
(
$key_n
ame
);
$non
_unique
=
strtolower
(
$non_u
nique
);
$key
Name
=
strtolower
(
$keyN
ame
);
$non
Unique
=
strtolower
(
$nonU
nique
);
}
else
{
$key
_name
=
strtoupper
(
$key_n
ame
);
$non
_unique
=
strtoupper
(
$non_u
nique
);
$key
Name
=
strtoupper
(
$keyN
ame
);
$non
Unique
=
strtoupper
(
$nonU
nique
);
}
}
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
,
true
);
$query
=
"SHOW INDEX FROM
$table
"
;
$query
=
'SHOW INDEX FROM '
.
$table
;
$indexes
=
$this
->
conn
->
fetchAssoc
(
$query
);
$result
=
array
();
foreach
(
$indexes
as
$index
_d
ata
)
{
if
(
!
$index
_data
[
$non_u
nique
])
{
if
(
$index
_data
[
$key_n
ame
]
!==
'PRIMARY'
)
{
$index
=
$this
->
_fixIndexName
(
$index_data
[
$key_n
ame
]);
foreach
(
$indexes
as
$index
D
ata
)
{
if
(
!
$index
Data
[
$nonU
nique
])
{
if
(
$index
Data
[
$keyN
ame
]
!==
'PRIMARY'
)
{
$index
=
$this
->
conn
->
fixIndexName
(
$indexData
[
$keyN
ame
]);
}
else
{
$index
=
'PRIMARY'
;
}
if
(
!
empty
(
$index
))
{
$result
[
$index
]
=
true
;
}
if
(
!
empty
(
$index
))
{
$result
[]
=
$index
;
}
}
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_change_key_case
(
$result
,
$this
->
conn
->
options
[
'field_case'
]);
}
return
array_keys
(
$result
)
;
return
$result
;
}
/**
* lists table constraints
...
...
@@ -161,15 +131,15 @@ class Doctrine_Import_Mysql extends Doctrine_Import
*/
public
function
listTableIndexes
(
$table
)
{
$key
_n
ame
=
'Key_name'
;
$non
_u
nique
=
'Non_unique'
;
$key
N
ame
=
'Key_name'
;
$non
U
nique
=
'Non_unique'
;
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
if
(
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
)
{
$key
_name
=
strtolower
(
$key_n
ame
);
$non
_unique
=
strtolower
(
$non_u
nique
);
$key
Name
=
strtolower
(
$keyN
ame
);
$non
Unique
=
strtolower
(
$nonU
nique
);
}
else
{
$key
_n
ame
=
strtoupper
(
$key_name
);
$non
_unique
=
strtoupper
(
$non_u
nique
);
$key
N
ame
=
strtoupper
(
$key_name
);
$non
Unique
=
strtoupper
(
$nonU
nique
);
}
}
...
...
@@ -179,16 +149,12 @@ class Doctrine_Import_Mysql extends Doctrine_Import
$result
=
array
();
foreach
(
$indexes
as
$index
_d
ata
)
{
if
(
$index
_data
[
$non_unique
]
&&
(
$index
=
$this
->
_fixIndexName
(
$index_data
[
$key_n
ame
])))
{
$result
[
$index
]
=
true
;
foreach
(
$indexes
as
$index
D
ata
)
{
if
(
$index
Data
[
$nonUnique
]
&&
(
$index
=
$this
->
conn
->
fixIndexName
(
$indexData
[
$keyN
ame
])))
{
$result
[
]
=
$index
;
}
}
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_change_key_case
(
$result
,
$this
->
conn
->
options
[
'field_case'
]);
}
return
array_keys
(
$result
);
return
$result
;
}
/**
* lists tables
...
...
@@ -199,26 +165,6 @@ class Doctrine_Import_Mysql extends Doctrine_Import
public
function
listTables
(
$database
=
null
)
{
return
$this
->
conn
->
fetchColumn
(
$this
->
sql
[
'listTables'
]);
}
/**
* lists table triggers
*
* @param string $table database table name
* @return array
*/
public
function
listTableTriggers
(
$table
)
{
}
/**
* lists table views
*
* @param string $table database table name
* @return array
*/
public
function
listTableViews
(
$table
)
{
}
/**
* lists database views
...
...
lib/Doctrine/Import/Oracle.php
View file @
4ff559ce
...
...
@@ -64,6 +64,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
public
function
listFunctions
()
{
$query
=
"SELECT name FROM sys.user_source WHERE line = 1 AND type = 'FUNCTION'"
;
return
$this
->
conn
->
fetchColumn
(
$query
);
}
/**
...
...
@@ -87,7 +88,7 @@ class Doctrine_Import_Oracle extends Doctrine_Import
$query
=
"SELECT sequence_name FROM sys.user_sequences"
;
$tableNames
=
$this
->
conn
->
fetchColumn
(
$query
);
return
array_map
(
array
(
$this
->
conn
,
'fixSequenceName'
),
$
result
);
return
array_map
(
array
(
$this
->
conn
,
'fixSequenceName'
),
$
tableNames
);
}
/**
* lists table constraints
...
...
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