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
fa5ab7d2
Commit
fa5ab7d2
authored
Jan 10, 2008
by
lsmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- moved getIntegerDeclaration to export since we already have getDeclaration in there
parent
b1df27b1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
177 additions
and
185 deletions
+177
-185
Mysql.php
lib/Doctrine/DataDict/Mysql.php
+0
-51
Pgsql.php
lib/Doctrine/DataDict/Pgsql.php
+0
-54
Sqlite.php
lib/Doctrine/DataDict/Sqlite.php
+1
-57
Export.php
lib/Doctrine/Export.php
+2
-3
Mysql.php
lib/Doctrine/Export/Mysql.php
+51
-0
Pgsql.php
lib/Doctrine/Export/Pgsql.php
+59
-10
Sqlite.php
lib/Doctrine/Export/Sqlite.php
+64
-10
No files found.
lib/Doctrine/DataDict/Mysql.php
View file @
fa5ab7d2
...
...
@@ -413,55 +413,4 @@ class Doctrine_DataDict_Mysql extends Doctrine_DataDict
{
return
'COLLATE '
.
$collation
;
}
/**
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
*
* @param string $name name the field to be declared.
* @param string $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:
*
* unsigned
* Boolean flag that indicates whether the field
* should be declared as unsigned integer if
* possible.
*
* default
* Integer 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.
*/
public
function
getIntegerDeclaration
(
$name
,
$field
)
{
$default
=
$autoinc
=
''
;
if
(
!
empty
(
$field
[
'autoincrement'
]))
{
$autoinc
=
' AUTO_INCREMENT'
;
}
elseif
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
if
(
is_null
(
$field
[
'default'
]))
{
$default
=
' DEFAULT NULL'
;
}
else
{
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
]);
}
}
elseif
(
empty
(
$field
[
'notnull'
]))
{
$default
=
' DEFAULT NULL'
;
}
$notnull
=
(
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
])
?
' NOT NULL'
:
''
;
$unsigned
=
(
isset
(
$field
[
'unsigned'
])
&&
$field
[
'unsigned'
])
?
' UNSIGNED'
:
''
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
getNativeDeclaration
(
$field
)
.
$unsigned
.
$default
.
$notnull
.
$autoinc
;
}
}
lib/Doctrine/DataDict/Pgsql.php
View file @
fa5ab7d2
...
...
@@ -559,60 +559,6 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
'fixed'
=>
$fixed
);
}
/**
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
*
* @param string $name name the field to be declared.
* @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:
*
* unsigned
* Boolean flag that indicates whether the field should be
* declared as unsigned integer if possible.
*
* default
* Integer 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.
*/
public
function
getIntegerDeclaration
(
$name
,
$field
)
{
/**
if ( ! empty($field['unsigned'])) {
$this->conn->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
}
*/
if
(
!
empty
(
$field
[
'autoincrement'
]))
{
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
getNativeDeclaration
(
$field
);
}
$default
=
''
;
if
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
/**
TODO: is this needed ?
elseif (empty($field['notnull'])) {
$default = ' DEFAULT NULL';
}
*/
$notnull
=
empty
(
$field
[
'notnull'
])
?
''
:
' NOT NULL'
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
getNativeDeclaration
(
$field
)
.
$default
.
$notnull
;
}
/**
* parseBoolean
* parses a literal boolean value and returns
...
...
lib/Doctrine/DataDict/Sqlite.php
View file @
fa5ab7d2
...
...
@@ -241,60 +241,4 @@ class Doctrine_DataDict_Sqlite extends Doctrine_DataDict
'unsigned'
=>
$unsigned
,
'fixed'
=>
$fixed
);
}
/**
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
*
* @param string $name name the field to be declared.
* @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:
*
* unsigned
* Boolean flag that indicates whether the field
* should be declared as unsigned integer if
* possible.
*
* default
* Integer 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 protected
*/
public
function
getIntegerDeclaration
(
$name
,
array
$field
)
{
$default
=
$autoinc
=
''
;
$type
=
$this
->
getNativeDeclaration
(
$field
);
$autoincrement
=
isset
(
$field
[
'autoincrement'
])
&&
$field
[
'autoincrement'
];
if
(
$autoincrement
)
{
$autoinc
=
' PRIMARY KEY AUTOINCREMENT'
;
$type
=
'INTEGER'
;
}
elseif
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
/**
elseif (empty($field['notnull'])) {
$default = ' DEFAULT NULL';
}
*/
$notnull
=
(
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
])
?
' NOT NULL'
:
''
;
// sqlite does not support unsigned attribute for autoinremented fields
$unsigned
=
(
isset
(
$field
[
'unsigned'
])
&&
$field
[
'unsigned'
]
&&
!
$autoincrement
)
?
' UNSIGNED'
:
''
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$type
.
$unsigned
.
$default
.
$notnull
.
$autoinc
;
}
}
lib/Doctrine/Export.php
View file @
fa5ab7d2
...
...
@@ -693,11 +693,10 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/
public
function
getDeclaration
(
$name
,
array
$field
)
{
$method
=
'get'
.
$field
[
'type'
]
.
'Declaration'
;
if
(
method_exists
(
$this
->
conn
->
dataDict
,
$method
))
{
return
$this
->
conn
->
dataDict
->
$method
(
$name
,
$field
);
if
(
method_exists
(
$this
,
$method
))
{
return
$this
->
$method
(
$name
,
$field
);
}
$default
=
$this
->
getDefaultFieldDeclaration
(
$field
);
...
...
lib/Doctrine/Export/Mysql.php
View file @
fa5ab7d2
...
...
@@ -502,6 +502,57 @@ class Doctrine_Export_Mysql extends Doctrine_Export
return
$query
;
}
/**
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
*
* @param string $name name the field to be declared.
* @param string $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:
*
* unsigned
* Boolean flag that indicates whether the field
* should be declared as unsigned integer if
* possible.
*
* default
* Integer 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.
*/
public
function
getIntegerDeclaration
(
$name
,
$field
)
{
$default
=
$autoinc
=
''
;
if
(
!
empty
(
$field
[
'autoincrement'
]))
{
$autoinc
=
' AUTO_INCREMENT'
;
}
elseif
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
if
(
is_null
(
$field
[
'default'
]))
{
$default
=
' DEFAULT NULL'
;
}
else
{
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
]);
}
}
elseif
(
empty
(
$field
[
'notnull'
]))
{
$default
=
' DEFAULT NULL'
;
}
$notnull
=
(
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
])
?
' NOT NULL'
:
''
;
$unsigned
=
(
isset
(
$field
[
'unsigned'
])
&&
$field
[
'unsigned'
])
?
' UNSIGNED'
:
''
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
conn
->
dataDict
->
getNativeDeclaration
(
$field
)
.
$unsigned
.
$default
.
$notnull
.
$autoinc
;
}
/**
* getDefaultDeclaration
* Obtain DBMS specific SQL code portion needed to set a default value
...
...
lib/Doctrine/Export/Pgsql.php
View file @
fa5ab7d2
...
...
@@ -360,4 +360,53 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
return
$sql
;
}
/**
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
*
* @param string $name name the field to be declared.
* @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:
*
* unsigned
* Boolean flag that indicates whether the field should be
* declared as unsigned integer if possible.
*
* default
* Integer 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.
*/
public
function
getIntegerDeclaration
(
$name
,
$field
)
{
/**
if ( ! empty($field['unsigned'])) {
$this->conn->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
}
*/
if
(
!
empty
(
$field
[
'autoincrement'
]))
{
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
conn
->
dataDict
->
getNativeDeclaration
(
$field
);
}
$default
=
''
;
if
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
elseif
(
empty
(
$field
[
'notnull'
]))
{
$default
=
' DEFAULT NULL'
;
}
$notnull
=
empty
(
$field
[
'notnull'
])
?
''
:
' NOT NULL'
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
conn
->
dataDict
->
getNativeDeclaration
(
$field
)
.
$default
.
$notnull
;
}
}
lib/Doctrine/Export/Sqlite.php
View file @
fa5ab7d2
...
...
@@ -413,4 +413,58 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
return
'ALTER TABLE '
.
$name
.
' '
.
$query
;
}
/**
* Obtain DBMS specific SQL code portion needed to declare an integer type
* field to be used in statements like CREATE TABLE.
*
* @param string $name name the field to be declared.
* @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:
*
* unsigned
* Boolean flag that indicates whether the field
* should be declared as unsigned integer if
* possible.
*
* default
* Integer 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 protected
*/
public
function
getIntegerDeclaration
(
$name
,
array
$field
)
{
$default
=
$autoinc
=
''
;
$type
=
$this
->
conn
->
dataDict
->
getNativeDeclaration
(
$field
);
$autoincrement
=
isset
(
$field
[
'autoincrement'
])
&&
$field
[
'autoincrement'
];
if
(
$autoincrement
)
{
$autoinc
=
' PRIMARY KEY AUTOINCREMENT'
;
$type
=
'INTEGER'
;
}
elseif
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
$default
=
' DEFAULT '
.
$this
->
conn
->
quote
(
$field
[
'default'
],
$field
[
'type'
]);
}
elseif
(
empty
(
$field
[
'notnull'
]))
{
$default
=
' DEFAULT NULL'
;
}
$notnull
=
(
isset
(
$field
[
'notnull'
])
&&
$field
[
'notnull'
])
?
' NOT NULL'
:
''
;
// sqlite does not support unsigned attribute for autoinremented fields
$unsigned
=
(
isset
(
$field
[
'unsigned'
])
&&
$field
[
'unsigned'
]
&&
!
$autoincrement
)
?
' UNSIGNED'
:
''
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$type
.
$unsigned
.
$default
.
$notnull
.
$autoinc
;
}
}
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