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
4a1bff14
Commit
4a1bff14
authored
Nov 30, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
faa5e603
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
50 deletions
+54
-50
Mysql.php
lib/Doctrine/Connection/Mysql.php
+7
-7
Mysql.php
lib/Doctrine/DataDict/Mysql.php
+8
-8
Sqlite.php
lib/Doctrine/DataDict/Sqlite.php
+7
-7
MysqlTestCase.php
tests/DataDict/MysqlTestCase.php
+32
-28
No files found.
lib/Doctrine/Connection/Mysql.php
View file @
4a1bff14
...
...
@@ -197,14 +197,14 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
for
(
reset
(
$fields
);
$colnum
<
$count
;
next
(
$fields
),
$colnum
++
)
{
$name
=
key
(
$fields
);
if
(
$colnum
>
0
)
{
if
(
$colnum
>
0
)
{
$query
.=
','
;
$values
.=
','
;
}
$query
.=
$name
;
if
(
isset
(
$fields
[
$name
][
'null'
])
&&
$fields
[
$name
][
'null'
])
{
if
(
isset
(
$fields
[
$name
][
'null'
])
&&
$fields
[
$name
][
'null'
])
{
$value
=
'NULL'
;
}
else
{
$type
=
isset
(
$fields
[
$name
][
'type'
])
?
$fields
[
$name
][
'type'
]
:
null
;
...
...
@@ -213,15 +213,15 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common {
$values
.=
$value
;
if
(
isset
(
$fields
[
$name
][
'key'
])
&&
$fields
[
$name
][
'key'
])
{
if
(
$value
===
'NULL'
)
if
(
isset
(
$fields
[
$name
][
'key'
])
&&
$fields
[
$name
][
'key'
])
{
if
(
$value
===
'NULL'
)
throw
new
Doctrine_Connection_Mysql_Exception
(
'key value '
.
$name
.
' may not be NULL'
);
$keys
++
;
}
}
if
(
$keys
==
0
)
if
(
$keys
==
0
)
throw
new
Doctrine_Connection_Mysql_Exception
(
'not specified which fields are keys'
);
...
...
lib/Doctrine/DataDict/Mysql.php
View file @
4a1bff14
...
...
@@ -134,11 +134,11 @@ class Doctrine_DataDict_Mysql extends Doctrine_Connection_Module {
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
*/
public
function
getPortableDeclaration
(
$field
)
{
$db
_t
ype
=
strtolower
(
$field
[
'type'
]);
$db
_type
=
strtok
(
$db_t
ype
,
'(), '
);
if
(
$db
_t
ype
==
'national'
)
{
$db
_t
ype
=
strtok
(
'(), '
);
public
function
getPortableDeclaration
(
array
$field
)
{
$db
T
ype
=
strtolower
(
$field
[
'type'
]);
$db
Type
=
strtok
(
$dbT
ype
,
'(), '
);
if
(
$db
T
ype
==
'national'
)
{
$db
T
ype
=
strtok
(
'(), '
);
}
if
(
!
empty
(
$field
[
'length'
]))
{
$length
=
$field
[
'length'
];
...
...
@@ -149,7 +149,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_Connection_Module {
}
$type
=
array
();
$unsigned
=
$fixed
=
null
;
switch
(
$db
_t
ype
)
{
switch
(
$db
T
ype
)
{
case
'tinyint'
:
$type
[]
=
'integer'
;
$type
[]
=
'boolean'
;
...
...
@@ -195,7 +195,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_Connection_Module {
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$db
_t
ype
,
'text'
))
{
}
elseif
(
strstr
(
$db
T
ype
,
'text'
))
{
$type
[]
=
'clob'
;
if
(
$decimal
==
'binary'
)
{
$type
[]
=
'blob'
;
...
...
@@ -265,7 +265,7 @@ class Doctrine_DataDict_Mysql extends Doctrine_Connection_Module {
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Mysql_Exception
(
'unknown database attribute type: '
.
$db
_t
ype
);
throw
new
Doctrine_DataDict_Mysql_Exception
(
'unknown database attribute type: '
.
$db
T
ype
);
}
return
array
(
$type
,
$length
,
$unsigned
,
$fixed
);
...
...
lib/Doctrine/DataDict/Sqlite.php
View file @
4a1bff14
...
...
@@ -120,13 +120,13 @@ class Doctrine_DataDict_Sqlite extends Doctrine_Connection_Module {
* @param array $field native field description
* @return array containing the various possible types, length, sign, fixed
*/
public
function
getPortableDeclaration
(
$field
)
{
$db
_t
ype
=
strtolower
(
$field
[
'type'
]);
$length
=
!
empty
(
$field
[
'length'
]
)
?
$field
[
'length'
]
:
null
;
$unsigned
=
!
empty
(
$field
[
'unsigned'
]
)
?
$field
[
'unsigned'
]
:
null
;
public
function
getPortableDeclaration
(
array
$field
)
{
$db
T
ype
=
strtolower
(
$field
[
'type'
]);
$length
=
(
!
empty
(
$field
[
'length'
])
)
?
$field
[
'length'
]
:
null
;
$unsigned
=
(
!
empty
(
$field
[
'unsigned'
])
)
?
$field
[
'unsigned'
]
:
null
;
$fixed
=
null
;
$type
=
array
();
switch
(
$db
_t
ype
)
{
switch
(
$db
T
ype
)
{
case
'boolean'
:
$type
[]
=
'boolean'
;
break
;
...
...
@@ -177,7 +177,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_Connection_Module {
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$db
_t
ype
,
'text'
))
{
}
elseif
(
strstr
(
$db
T
ype
,
'text'
))
{
$type
[]
=
'clob'
;
}
if
(
$fixed
!==
false
)
{
...
...
@@ -221,7 +221,7 @@ class Doctrine_DataDict_Sqlite extends Doctrine_Connection_Module {
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Sqlite_Exception
(
'unknown database attribute type: '
.
$db
_t
ype
);
throw
new
Doctrine_DataDict_Sqlite_Exception
(
'unknown database attribute type: '
.
$db
T
ype
);
}
return
array
(
$type
,
$length
,
$unsigned
,
$fixed
);
...
...
tests/DataDict/MysqlTestCase.php
View file @
4a1bff14
...
...
@@ -3,6 +3,10 @@ class Doctrine_DataDict_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
public
function
__construct
()
{
parent
::
__construct
(
'mysql'
);
}
public
function
testGetPortableDefinitionSupportsIntegers
()
{
$field
=
array
(
'INT UNSIGNED'
);
}
public
function
testGetNativeDefinitionSupportsIntegerType
()
{
$a
=
array
(
'type'
=>
'integer'
,
'length'
=>
20
,
'fixed'
=>
false
);
...
...
@@ -10,76 +14,76 @@ class Doctrine_DataDict_Mysql_TestCase extends Doctrine_Driver_UnitTestCase {
$a
[
'length'
]
=
4
;
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'INT'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'INT'
);
$a
[
'length'
]
=
2
;
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'SMALLINT'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'SMALLINT'
);
}
public
function
testGetNativeDe
fini
tionSupportsFloatType
()
{
public
function
testGetNativeDe
clara
tionSupportsFloatType
()
{
$a
=
array
(
'type'
=>
'float'
,
'length'
=>
20
,
'fixed'
=>
false
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'DOUBLE'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'DOUBLE'
);
}
public
function
testGetNativeDe
fini
tionSupportsBooleanType
()
{
public
function
testGetNativeDe
clara
tionSupportsBooleanType
()
{
$a
=
array
(
'type'
=>
'boolean'
,
'fixed'
=>
false
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'TINYINT(1)'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'TINYINT(1)'
);
}
public
function
testGetNativeDe
fini
tionSupportsDateType
()
{
public
function
testGetNativeDe
clara
tionSupportsDateType
()
{
$a
=
array
(
'type'
=>
'date'
,
'fixed'
=>
false
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'DATE'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'DATE'
);
}
public
function
testGetNativeDe
fini
tionSupportsTimestampType
()
{
public
function
testGetNativeDe
clara
tionSupportsTimestampType
()
{
$a
=
array
(
'type'
=>
'timestamp'
,
'fixed'
=>
false
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'DATETIME'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'DATETIME'
);
}
public
function
testGetNativeDe
fini
tionSupportsTimeType
()
{
public
function
testGetNativeDe
clara
tionSupportsTimeType
()
{
$a
=
array
(
'type'
=>
'time'
,
'fixed'
=>
false
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'TIME'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'TIME'
);
}
public
function
testGetNativeDe
fini
tionSupportsClobType
()
{
public
function
testGetNativeDe
clara
tionSupportsClobType
()
{
$a
=
array
(
'type'
=>
'clob'
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'LONGTEXT'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'LONGTEXT'
);
}
public
function
testGetNativeDe
fini
tionSupportsBlobType
()
{
public
function
testGetNativeDe
clara
tionSupportsBlobType
()
{
$a
=
array
(
'type'
=>
'blob'
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'LONGBLOB'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'LONGBLOB'
);
}
public
function
testGetNativeDe
fini
tionSupportsCharType
()
{
public
function
testGetNativeDe
clara
tionSupportsCharType
()
{
$a
=
array
(
'type'
=>
'char'
,
'length'
=>
10
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'CHAR(10)'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'CHAR(10)'
);
}
public
function
testGetNativeDe
fini
tionSupportsVarcharType
()
{
public
function
testGetNativeDe
clara
tionSupportsVarcharType
()
{
$a
=
array
(
'type'
=>
'varchar'
,
'length'
=>
10
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'VARCHAR(10)'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'VARCHAR(10)'
);
}
public
function
testGetNativeDe
fini
tionSupportsArrayType
()
{
public
function
testGetNativeDe
clara
tionSupportsArrayType
()
{
$a
=
array
(
'type'
=>
'array'
,
'length'
=>
40
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'VARCHAR(40)'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'VARCHAR(40)'
);
}
public
function
testGetNativeDe
fini
tionSupportsStringType
()
{
public
function
testGetNativeDe
clara
tionSupportsStringType
()
{
$a
=
array
(
'type'
=>
'string'
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'TEXT'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'TEXT'
);
}
public
function
testGetNativeDe
fini
tionSupportsArrayType2
()
{
public
function
testGetNativeDe
clara
tionSupportsArrayType2
()
{
$a
=
array
(
'type'
=>
'array'
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'TEXT'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'TEXT'
);
}
public
function
testGetNativeDe
fini
tionSupportsObjectType
()
{
public
function
testGetNativeDe
clara
tionSupportsObjectType
()
{
$a
=
array
(
'type'
=>
'object'
);
$this
->
assertEqual
(
$this
->
dataDict
->
g
etNativeDeclaration
(
$a
),
'TEXT'
);
$this
->
assertEqual
(
$this
->
dataDict
->
G
etNativeDeclaration
(
$a
),
'TEXT'
);
}
}
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