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
5bfd47cd
Commit
5bfd47cd
authored
Dec 30, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import drivers updated
parent
611c65e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
69 deletions
+39
-69
Mssql.php
lib/Doctrine/Import/Mssql.php
+2
-2
Mysql.php
lib/Doctrine/Import/Mysql.php
+23
-55
Oracle.php
lib/Doctrine/Import/Oracle.php
+11
-9
Pgsql.php
lib/Doctrine/Import/Pgsql.php
+1
-1
Sqlite.php
lib/Doctrine/Import/Sqlite.php
+2
-2
No files found.
lib/Doctrine/Import/Mssql.php
View file @
5bfd47cd
...
...
@@ -105,7 +105,7 @@ class Doctrine_Import_Mssql extends Doctrine_Import
public
function
listTableColumns
(
$table
)
{
$sql
=
'EXEC sp_columns @table_name = '
.
$this
->
quoteIdentifier
(
$table
);
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$result
=
$this
->
conn
->
fetchAssoc
(
$sql
);
$columns
=
array
();
foreach
(
$result
as
$key
=>
$val
)
{
...
...
@@ -127,7 +127,7 @@ class Doctrine_Import_Mssql extends Doctrine_Import
'default'
=>
$val
[
'column_def'
],
'primary'
=>
(
strtolower
(
$identity
)
==
'identity'
),
);
$columns
[
$val
[
'column_name'
]]
=
new
Doctrine_Schema_Column
(
$description
)
;
$columns
[
$val
[
'column_name'
]]
=
$description
;
}
return
$columns
;
...
...
lib/Doctrine/Import/Mysql.php
View file @
5bfd47cd
...
...
@@ -31,17 +31,15 @@ Doctrine::autoload('Doctrine_Import');
*/
class
Doctrine_Import_Mysql
extends
Doctrine_Import
{
/**
* lists all databases
*
* @return array
*/
public
function
listDatabases
()
{
$sql
=
'SHOW DATABASES'
;
return
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_COLUMN
);
}
protected
$sql
=
array
(
'showDatabases'
=>
'SHOW DATABASES'
,
'listTableFields'
=>
'DESCRIBE %s'
,
'listSequences'
=>
'SHOW TABLES'
,
'listTables'
=>
'SHOW TABLES'
,
'listUsers'
=>
'SELECT DISTINCT USER FROM USER'
,
'listViews'
=>
"SHOW FULL TABLES %sWHERE Table_type = 'VIEW'"
,
);
/**
* lists all availible database functions
*
...
...
@@ -73,7 +71,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
if
(
!
is_null
(
$database
))
{
$query
.=
" FROM
$database
"
;
}
$tableNames
=
$
db
->
queryCol
(
$query
);
$tableNames
=
$
this
->
conn
->
fetchColumn
(
$query
);
$result
=
array
();
foreach
(
$tableNames
as
$tableName
)
{
...
...
@@ -81,9 +79,6 @@ class Doctrine_Import_Mysql extends Doctrine_Import
$result
[]
=
$sqn
;
}
}
if
(
$db
->
options
[
'portability'
]
&
MDB2_PORTABILITY_FIX_CASE
)
{
$result
=
array_map
((
$db
->
options
[
'field_case'
]
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
}
return
$result
;
}
/**
...
...
@@ -94,11 +89,6 @@ class Doctrine_Import_Mysql extends Doctrine_Import
*/
public
function
listTableConstraints
(
$table
)
{
$db
=&
$this
->
getDBInstance
();
if
(
PEAR
::
isError
(
$db
))
{
return
$db
;
}
$key_name
=
'Key_name'
;
$non_unique
=
'Non_unique'
;
if
(
$db
->
options
[
'portability'
]
&
MDB2_PORTABILITY_FIX_CASE
)
{
...
...
@@ -114,9 +104,6 @@ class Doctrine_Import_Mysql extends Doctrine_Import
$table
=
$db
->
quoteIdentifier
(
$table
,
true
);
$query
=
"SHOW INDEX FROM
$table
"
;
$indexes
=
$db
->
queryAll
(
$query
,
null
,
MDB2_FETCHMODE_ASSOC
);
if
(
PEAR
::
isError
(
$indexes
))
{
return
$indexes
;
}
$result
=
array
();
foreach
(
$indexes
as
$index_data
)
{
...
...
@@ -132,7 +119,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
}
}
if
(
$db
->
options
[
'portability'
]
&
MDB2_
PORTABILITY_FIX_CASE
)
{
if
(
$db
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_change_key_case
(
$result
,
$db
->
options
[
'field_case'
]);
}
return
array_keys
(
$result
);
...
...
@@ -145,23 +132,22 @@ class Doctrine_Import_Mysql extends Doctrine_Import
*/
public
function
listTableColumns
(
$table
)
{
$sql
=
"DESCRIBE
$table
"
;
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$sql
=
'DESCRIBE '
.
$table
;
$result
=
$this
->
conn
->
fetchAssoc
(
$sql
);
$description
=
array
();
foreach
(
$result
as
$key
=>
$val2
)
{
$val
=
array
();
foreach
(
array_keys
(
$val2
)
as
$valKey
){
// lowercase the key names
$val
[
strtolower
(
$valKey
)]
=
$val2
[
$valKey
];
}
foreach
(
$result
as
$key
=>
$val
)
{
array_change_key_case
(
$val
,
CASE_LOWER
);
$description
=
array
(
'name'
=>
$val
[
'field'
],
'type'
=>
$val
[
'type'
],
'primary'
=>
(
strtolower
(
$val
[
'key'
])
==
'pri'
),
'default'
=>
$val
[
'default'
],
'notnull'
=>
(
bool
)
(
$val
[
'null'
]
!=
'YES'
),
'autoinc'
=>
(
bool
)
(
strpos
(
$val
[
'extra'
],
'auto_increment'
)
>
-
1
),
'autoinc'
=>
(
bool
)
(
strpos
(
$val
[
'extra'
],
'auto_increment'
)
!==
false
),
);
$columns
[
$val
[
'field'
]]
=
new
Doctrine_Schema_Column
(
$description
)
;
$columns
[
$val
[
'field'
]]
=
$description
;
}
...
...
@@ -212,9 +198,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
*/
public
function
listTables
(
$database
=
null
)
{
$sql
=
'SHOW TABLES'
;
return
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_COLUMN
);
return
$this
->
conn
->
fetchColumn
(
$this
->
sql
[
'listTables'
]);
}
/**
* lists table triggers
...
...
@@ -235,15 +219,6 @@ class Doctrine_Import_Mysql extends Doctrine_Import
public
function
listTableViews
(
$table
)
{
}
/**
* lists database users
*
* @return array
*/
public
function
listUsers
()
{
return
$db
->
queryCol
(
'SELECT DISTINCT USER FROM USER'
);
}
/**
* lists database views
...
...
@@ -253,17 +228,10 @@ class Doctrine_Import_Mysql extends Doctrine_Import
*/
public
function
listViews
(
$database
=
null
)
{
$query
=
'SHOW FULL TABLES'
;
if
(
!
is_null
(
$database
))
{
$query
.=
' FROM '
.
$database
;
}
$query
.=
" WHERE Table_type = 'VIEW'"
;
$result
=
$db
->
queryCol
(
$query
);
$query
=
sprintf
(
$this
->
sql
[
'listViews'
],
' FROM '
.
$database
);
}
if
(
$db
->
options
[
'portability'
]
&
MDB2_PORTABILITY_FIX_CASE
)
{
$result
=
array_map
((
$db
->
options
[
'field_case'
]
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
}
return
$result
;
return
$this
->
conn
->
fetchColumn
(
$query
);
}
}
lib/Doctrine/Import/Oracle.php
View file @
5bfd47cd
...
...
@@ -145,16 +145,18 @@ class Doctrine_Import_Oracle extends Doctrine_Import
*/
public
function
listTableColumns
(
$table
)
{
$table
=
strtoupper
(
$table
);
$sql
=
"SELECT column_name, data_type, data_length, nullable, data_default from all_tab_columns WHERE table_name='
$table
' ORDER BY column_name"
;
$result
=
$this
->
conn
->
fetchAssoc
(
$sql
);
$table
=
$this
->
conn
->
quote
(
$table
,
'text'
);
$query
=
'SELECT column_name FROM user_tab_columns'
;
$query
.=
' WHERE table_name='
.
$table
.
' OR table_name='
.
strtoupper
(
$table
)
.
' ORDER BY column_id'
;
$result
=
$this
->
conn
->
queryCol
(
$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
);
foreach
(
$result
as
$val
)
{
$descr
[
$val
[
'column_name'
]]
=
array
(
'name'
=>
$val
[
'column_name'
],
'notnull'
=>
(
bool
)
(
$val
[
'nullable'
]
===
'N'
),
// nullable is N when mandatory
'type'
=>
$val
[
'data_type'
],
'default'
=>
$val
[
'data_default'
],
'length'
=>
$val
[
'data_length'
]
);
}
return
$result
;
}
...
...
lib/Doctrine/Import/Pgsql.php
View file @
5bfd47cd
...
...
@@ -165,7 +165,7 @@ class Doctrine_Import_Pgsql extends Doctrine_Import
'default'
=>
$val
[
'default'
],
'primary'
=>
(
$val
[
'pri'
]
==
't'
),
);
$columns
[
$val
[
'field'
]]
=
new
Doctrine_Schema_Column
(
$description
)
;
$columns
[
$val
[
'field'
]]
=
$description
;
}
return
$columns
;
}
...
...
lib/Doctrine/Import/Sqlite.php
View file @
5bfd47cd
...
...
@@ -129,7 +129,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
{
$sql
=
'PRAGMA table_info('
.
$table
.
')'
;
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$result
=
$this
->
conn
->
fetchAll
(
$sql
);
$description
=
array
();
$columns
=
array
();
...
...
@@ -141,7 +141,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
'default'
=>
$val
[
'dflt_value'
],
'primary'
=>
(
bool
)
$val
[
'pk'
],
);
$columns
[
$val
[
'name'
]]
=
new
Doctrine_Schema_Column
(
$description
)
;
$columns
[
$val
[
'name'
]]
=
$description
;
}
return
$columns
;
}
...
...
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