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
20f50425
Commit
20f50425
authored
Oct 19, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Mysql export driver + updated some datadict drivers
parent
7dabc662
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
527 additions
and
6 deletions
+527
-6
Mysql.php
lib/Doctrine/DataDict/Mysql.php
+95
-1
Sqlite.php
lib/Doctrine/DataDict/Sqlite.php
+4
-4
Export.php
lib/Doctrine/Export.php
+9
-1
Mysql.php
lib/Doctrine/Export/Mysql.php
+410
-0
ExportMysqlTestCase.php
tests/ExportMysqlTestCase.php
+7
-0
UnitTestCase.php
tests/UnitTestCase.php
+2
-0
No files found.
lib/Doctrine/DataDict/Mysql.php
View file @
20f50425
...
@@ -24,10 +24,104 @@
...
@@ -24,10 +24,104 @@
* @url http://www.phpdoctrine.com
* @url http://www.phpdoctrine.com
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen
* @author Konsta Vesterinen
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @version $Id$
* @version $Id$
*/
*/
class
Doctrine_DataDict_Mysql
extends
Doctrine_DataDict
{
class
Doctrine_DataDict_Mysql
extends
Doctrine_DataDict
{
/**
* Obtain DBMS specific SQL code portion needed to declare an text type
* field to be used in statements like CREATE TABLE.
*
* @param array $field associative array with the name of the properties
* of the field being declared as array indexes. Currently, the types
* of supported field properties are as follows:
*
* length
* Integer value that determines the maximum length of the text
* field. If this argument is missing the field should be
* declared to have the longest length allowed by the DBMS.
*
* default
* Text value to be used as default for this field.
*
* notnull
* Boolean flag that indicates whether this field is constrained
* to not be set to null.
* @return string DBMS specific SQL code portion that should be used to
* declare the specified field.
* @access public
*/
public
function
getTypeDeclaration
(
$field
)
{
switch
(
$field
[
'type'
])
{
case
'array'
:
case
'object'
:
case
'string'
:
if
(
empty
(
$field
[
'length'
])
&&
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
dbh
->
varchar_max_length
;
}
$length
=
(
!
empty
(
$field
[
'length'
]))
?
$field
[
'length'
]
:
false
;
$fixed
=
(
!
empty
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
case
'clob'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
255
)
{
return
'TINYTEXT'
;
}
elseif
(
$length
<=
65532
)
{
return
'TEXT'
;
}
elseif
(
$length
<=
16777215
)
{
return
'MEDIUMTEXT'
;
}
}
return
'LONGTEXT'
;
case
'blob'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
255
)
{
return
'TINYBLOB'
;
}
elseif
(
$length
<=
65532
)
{
return
'BLOB'
;
}
elseif
(
$length
<=
16777215
)
{
return
'MEDIUMBLOB'
;
}
}
return
'LONGBLOB'
;
case
'integer'
:
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
if
(
$length
<=
1
)
{
return
'TINYINT'
;
}
elseif
(
$length
==
2
)
{
return
'SMALLINT'
;
}
elseif
(
$length
==
3
)
{
return
'MEDIUMINT'
;
}
elseif
(
$length
==
4
)
{
return
'INT'
;
}
elseif
(
$length
>
4
)
{
return
'BIGINT'
;
}
}
return
'INT'
;
case
'boolean'
:
return
'TINYINT(1)'
;
case
'date'
:
return
'DATE'
;
case
'time'
:
return
'TIME'
;
case
'timestamp'
:
return
'DATETIME'
;
case
'float'
:
return
'DOUBLE'
;
case
'decimal'
:
$length
=
!
empty
(
$field
[
'length'
])
?
$field
[
'length'
]
:
18
;
return
'DECIMAL('
.
$length
.
','
.
$this
->
dbh
->
options
[
'decimal_places'
]
.
')'
;
}
return
''
;
}
/**
/**
* lists all databases
* lists all databases
*
*
...
@@ -111,7 +205,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
...
@@ -111,7 +205,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict {
* @return array
* @return array
*/
*/
public
function
listTables
(
$database
=
null
)
{
public
function
listTables
(
$database
=
null
)
{
$sql
=
"SHOW TABLES"
;
$sql
=
'SHOW TABLES'
;
return
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
return
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
}
...
...
lib/Doctrine/DataDict/Sqlite.php
View file @
20f50425
...
@@ -79,7 +79,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
...
@@ -79,7 +79,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
*/
*/
public
function
listTableColumns
(
$table
)
{
public
function
listTableColumns
(
$table
)
{
$sql
=
"PRAGMA table_info(
$table
)"
;
$sql
=
"PRAGMA table_info(
$table
)"
;
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$result
=
$this
->
dbh
->
query
(
$sql
)
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
$description
=
array
();
$description
=
array
();
...
@@ -112,9 +112,9 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
...
@@ -112,9 +112,9 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict {
* @return array
* @return array
*/
*/
public
function
listTables
(
$database
=
null
)
{
public
function
listTables
(
$database
=
null
)
{
$sql
=
"SELECT name FROM sqlite_master WHERE type
=
'table' "
$sql
=
"SELECT name FROM sqlite_master WHERE type
=
'table' "
.
"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
();
$tables
=
array
();
$stmt
=
$this
->
dbh
->
query
(
$sql
);
$stmt
=
$this
->
dbh
->
query
(
$sql
);
...
...
lib/Doctrine/Export.php
View file @
20f50425
...
@@ -27,7 +27,15 @@
...
@@ -27,7 +27,15 @@
* @license LGPL
* @license LGPL
*/
*/
class
Doctrine_Export
{
class
Doctrine_Export
{
public
function
export
()
{
private
$conn
;
private
$dbh
;
public
function
__construct
(
$conn
)
{
$this
->
conn
=
$conn
;
$this
->
dbh
=
$conn
->
getDBH
();
}
public
function
export
()
{
$parent
=
new
ReflectionClass
(
'Doctrine_Record'
);
$parent
=
new
ReflectionClass
(
'Doctrine_Record'
);
$conn
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
();
$conn
=
Doctrine_Manager
::
getInstance
()
->
getCurrentConnection
();
$old
=
$conn
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
);
$old
=
$conn
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
);
...
...
lib/Doctrine/Export/Mysql.php
0 → 100644
View file @
20f50425
This diff is collapsed.
Click to expand it.
tests/ExportMysqlTestCase.php
0 → 100644
View file @
20f50425
<?php
class
Doctrine_Export_Mysql_TestCase
{
public
function
testCreateDatabase
()
{
}
}
?>
tests/UnitTestCase.php
View file @
20f50425
...
@@ -7,6 +7,8 @@ require_once dirname(__FILE__).'/../lib/Doctrine.php';
...
@@ -7,6 +7,8 @@ require_once dirname(__FILE__).'/../lib/Doctrine.php';
//Doctrine::loadAll();
//Doctrine::loadAll();
ini_set
(
'include_path'
,
$_SERVER
[
'DOCUMENT_ROOT'
]);
function
__autoload
(
$class
)
{
function
__autoload
(
$class
)
{
Doctrine
::
autoload
(
$class
);
Doctrine
::
autoload
(
$class
);
}
}
...
...
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