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
85559a7f
Commit
85559a7f
authored
Nov 25, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated pgsql expression and datadict drivers
parent
01efe0ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
104 additions
and
8 deletions
+104
-8
Pgsql.php
lib/Doctrine/DataDict/Pgsql.php
+48
-0
Pgsql.php
lib/Doctrine/Expression/Pgsql.php
+56
-8
No files found.
lib/Doctrine/DataDict/Pgsql.php
View file @
85559a7f
...
@@ -531,6 +531,54 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
...
@@ -531,6 +531,54 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict {
return
array
(
$type
,
$length
,
$unsigned
,
$fixed
);
return
array
(
$type
,
$length
,
$unsigned
,
$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'])) {
$db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
}
*/
if
(
!
empty
(
$field
[
'autoincrement'
]))
{
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
getTypeDeclaration
(
$field
);
}
$default
=
''
;
if
(
array_key_exists
(
'default'
,
$field
))
{
if
(
$field
[
'default'
]
===
''
)
{
$field
[
'default'
]
=
empty
(
$field
[
'notnull'
])
?
null
:
0
;
}
$default
=
' DEFAULT '
.
$this
->
quote
(
$field
[
'default'
],
'integer'
);
}
elseif
(
empty
(
$field
[
'notnull'
]))
{
$default
=
' DEFAULT NULL'
;
}
$notnull
=
empty
(
$field
[
'notnull'
])
?
''
:
' NOT NULL'
;
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
return
$name
.
' '
.
$this
->
getTypeDeclaration
(
$field
)
.
$default
.
$notnull
;
}
/**
/**
* listDatabases
* listDatabases
* lists all databases
* lists all databases
...
...
lib/Doctrine/Expression/Pgsql.php
View file @
85559a7f
...
@@ -22,14 +22,14 @@ Doctrine::autoload('Doctrine_Expression');
...
@@ -22,14 +22,14 @@ Doctrine::autoload('Doctrine_Expression');
/**
/**
* Doctrine_Expression_Pgsql
* Doctrine_Expression_Pgsql
*
*
* @package Doctrine
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @link www.phpdoctrine.com
* @since 1.0
* @since 1.0
* @version $Revision$
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
*/
class
Doctrine_Expression_Pgsql
extends
Doctrine_Expression
{
class
Doctrine_Expression_Pgsql
extends
Doctrine_Expression
{
/**
/**
* Returns the md5 sum of a field.
* Returns the md5 sum of a field.
...
@@ -110,4 +110,52 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
...
@@ -110,4 +110,52 @@ class Doctrine_Expression_Pgsql extends Doctrine_Expression {
public
function
random
()
{
public
function
random
()
{
return
'RANDOM()'
;
return
'RANDOM()'
;
}
}
/**
* build a pattern matching string
*
* EXPERIMENTAL
*
* WARNING: this function is experimental and may change signature at
* any time until labelled as non-experimental
*
* @access public
*
* @param array $pattern even keys are strings, odd are patterns (% and _)
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
* @param string $field optional field name that is being matched against
* (might be required when emulating ILIKE)
*
* @return string SQL pattern
*/
public
function
matchPattern
(
$pattern
,
$operator
=
null
,
$field
=
null
)
{
$match
=
''
;
if
(
!
is_null
(
$operator
))
{
$field
=
is_null
(
$field
)
?
''
:
$field
.
' '
;
$operator
=
strtoupper
(
$operator
);
switch
(
$operator
)
{
// case insensitive
case
'ILIKE'
:
$match
=
$field
.
'ILIKE '
;
break
;
// case sensitive
case
'LIKE'
:
$match
=
$field
.
'LIKE '
;
break
;
default
:
return
$db
->
raiseError
(
MDB2_ERROR_UNSUPPORTED
,
null
,
null
,
'not a supported operator type:'
.
$operator
,
__FUNCTION__
);
}
}
$match
.=
"'"
;
foreach
(
$pattern
as
$key
=>
$value
)
{
if
(
$key
%
2
)
{
$match
.=
$value
;
}
else
{
$match
.=
$db
->
escapePattern
(
$db
->
escape
(
$value
));
}
}
$match
.=
"'"
;
$match
.=
$this
->
patternEscapeString
();
return
$match
;
}
}
}
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