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
b3e59ab7
Commit
b3e59ab7
authored
Jan 14, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed sqlite import driver
parent
ca3cd10a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
31 deletions
+19
-31
Sqlite.php
lib/Doctrine/Import/Sqlite.php
+19
-31
No files found.
lib/Doctrine/Import/Sqlite.php
View file @
b3e59ab7
...
@@ -67,17 +67,17 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
...
@@ -67,17 +67,17 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
*/
*/
public
function
listSequences
(
$database
=
null
)
public
function
listSequences
(
$database
=
null
)
{
{
$query
=
"SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name"
;
$query
=
"SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name"
;
$table
_n
ames
=
$this
->
conn
->
fetchColumn
(
$query
);
$table
N
ames
=
$this
->
conn
->
fetchColumn
(
$query
);
$result
=
array
();
$result
=
array
();
foreach
(
$table
_names
as
$table_n
ame
)
{
foreach
(
$table
Names
as
$tableN
ame
)
{
if
(
$sqn
=
$this
->
_fixSequenceName
(
$table_n
ame
,
true
))
{
if
(
$sqn
=
$this
->
conn
->
fixSequenceName
(
$tableN
ame
,
true
))
{
$result
[]
=
$sqn
;
$result
[]
=
$sqn
;
}
}
}
}
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
if
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_map
((
$this
->
conn
->
options
[
'field_case'
]
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
$result
=
array_map
((
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_FIELD_CASE
)
==
CASE_LOWER
?
'strtolower'
:
'strtoupper'
),
$result
);
}
}
return
$result
;
return
$result
;
}
}
...
@@ -90,27 +90,29 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
...
@@ -90,27 +90,29 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
public
function
listTableConstraints
(
$table
)
public
function
listTableConstraints
(
$table
)
{
{
$table
=
$this
->
conn
->
quote
(
$table
,
'text'
);
$table
=
$this
->
conn
->
quote
(
$table
,
'text'
);
$query
=
"SELECT sql FROM sqlite_master WHERE type='index' AND "
;
$query
=
"SELECT sql FROM sqlite_master WHERE type='index' AND "
;
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$query
.=
'LOWER(tbl_name)='
.
strtolower
(
$table
);
if
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$query
.=
'LOWER(tbl_name) = '
.
strtolower
(
$table
);
}
else
{
}
else
{
$query
.=
"tbl_name=
$table
"
;
$query
.=
'tbl_name = '
.
$table
;
}
}
$query
.=
" AND sql NOT NULL ORDER BY name"
;
$query
.=
' AND sql NOT NULL ORDER BY name'
;
$indexes
=
$this
->
conn
->
fetchColumn
(
$query
);
$indexes
=
$this
->
conn
->
fetchColumn
(
$query
);
$result
=
array
();
$result
=
array
();
foreach
(
$indexes
as
$sql
)
{
foreach
(
$indexes
as
$sql
)
{
if
(
preg_match
(
"/^create unique index ([^ ]+) on /i"
,
$sql
,
$tmp
))
{
if
(
preg_match
(
"/^create unique index ([^ ]+) on /i"
,
$sql
,
$tmp
))
{
$index
=
$this
->
_
fixIndexName
(
$tmp
[
1
]);
$index
=
$this
->
conn
->
fixIndexName
(
$tmp
[
1
]);
if
(
!
empty
(
$index
))
{
if
(
!
empty
(
$index
))
{
$result
[
$index
]
=
true
;
$result
[
$index
]
=
true
;
}
}
}
}
}
}
if
(
$this
->
conn
->
options
[
'portability'
]
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
if
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_FIX_CASE
)
{
$result
=
array_change_key_case
(
$result
,
$this
->
conn
->
options
[
'field_case'
]
);
$result
=
array_change_key_case
(
$result
,
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_FIELD_CASE
)
);
}
}
return
array_keys
(
$result
);
return
array_keys
(
$result
);
}
}
...
@@ -122,7 +124,6 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
...
@@ -122,7 +124,6 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
*/
*/
public
function
listTableColumns
(
$table
)
public
function
listTableColumns
(
$table
)
{
{
$sql
=
'PRAGMA table_info('
.
$table
.
')'
;
$sql
=
'PRAGMA table_info('
.
$table
.
')'
;
$result
=
$this
->
conn
->
fetchAll
(
$sql
);
$result
=
$this
->
conn
->
fetchAll
(
$sql
);
...
@@ -149,13 +150,8 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
...
@@ -149,13 +150,8 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
public
function
listTableIndexes
(
$table
)
public
function
listTableIndexes
(
$table
)
{
{
$sql
=
'PRAGMA index_list('
.
$table
.
')'
;
$sql
=
'PRAGMA index_list('
.
$table
.
')'
;
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
return
$this
->
conn
->
fetchColumn
(
$sql
);
}
$indexes
=
array
();
foreach
(
$result
as
$key
=>
$val
)
{
}
}
/**
/**
* lists tables
* lists tables
*
*
...
@@ -168,15 +164,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
...
@@ -168,15 +164,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
.
"UNION ALL SELECT name FROM sqlite_temp_master "
.
"UNION ALL SELECT name FROM sqlite_temp_master "
.
"WHERE type = 'table' ORDER BY name"
;
.
"WHERE type = 'table' ORDER BY name"
;
$tables
=
array
();
return
$this
->
conn
->
fetchColumn
(
$sql
);
$stmt
=
$this
->
dbh
->
query
(
$sql
);
$data
=
$stmt
->
fetchAll
(
PDO
::
FETCH_COLUMN
);
foreach
(
$data
as
$table
)
{
$tables
[]
=
new
Doctrine_Schema_Table
(
array
(
'name'
=>
$table
));
}
return
$tables
;
}
}
/**
/**
* lists table triggers
* lists table triggers
...
...
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