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
d11a348b
Commit
d11a348b
authored
Mar 13, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-15'
parents
9cd6df38
de2318dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
Type.php
lib/Doctrine/DBAL/Types/Type.php
+40
-2
StringTest.php
tests/Doctrine/Tests/DBAL/Types/StringTest.php
+7
-0
No files found.
lib/Doctrine/DBAL/Types/Type.php
View file @
d11a348b
<?php
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
@@ -30,6 +28,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
...
@@ -30,6 +28,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
* A Type object is obtained by calling the static {@link getType()} method.
* A Type object is obtained by calling the static {@link getType()} method.
*
*
* @author Roman Borschel <roman@code-factory.org>
* @author Roman Borschel <roman@code-factory.org>
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @since 2.0
* @since 2.0
*/
*/
abstract
class
Type
abstract
class
Type
...
@@ -227,4 +226,43 @@ abstract class Type
...
@@ -227,4 +226,43 @@ abstract class Type
$e
=
explode
(
'\\'
,
get_class
(
$this
));
$e
=
explode
(
'\\'
,
get_class
(
$this
));
return
str_replace
(
'Type'
,
''
,
end
(
$e
));
return
str_replace
(
'Type'
,
''
,
end
(
$e
));
}
}
/**
* Does working with this column require SQL conversion functions?
*
* This is a metadata function that is required for example in the ORM.
* Usage of {@link convertToDatabaseValueSQL} and
* {@link convertToPHPValueSQL} works for any type and mostly
* does nothing. This method can additionally be used for optimization purposes.
*
* @return bool
*/
public
function
canRequireSQLConversion
()
{
return
false
;
}
/**
* Modifies the SQL expression (identifier, parameter) to convert to a database value.
*
* @param string $sqlExpr
* @param AbstractPlatform $platform
* @return string
*/
public
function
convertToDatabaseValueSQL
(
$sqlExpr
,
AbstractPlatform
$platform
)
{
return
$sqlExpr
;
}
/**
* Modifies the SQL expression (identifier, parameter) to convert to a PHP value.
*
* @param string $sqlExpr
* @param AbstractPlatform $platform
* @return string
*/
public
function
convertToPHPValueSQL
(
$sqlExpr
,
$platform
)
{
return
$sqlExpr
;
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Types/StringTest.php
View file @
d11a348b
...
@@ -39,4 +39,11 @@ class StringTest extends \Doctrine\Tests\DbalTestCase
...
@@ -39,4 +39,11 @@ class StringTest extends \Doctrine\Tests\DbalTestCase
{
{
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
$this
->
assertNull
(
$this
->
_type
->
convertToPHPValue
(
null
,
$this
->
_platform
));
}
}
public
function
testSQLConversion
()
{
$this
->
assertFalse
(
$this
->
_type
->
canRequireSQLConversion
(),
"String type can never require SQL conversion to work."
);
$this
->
assertEquals
(
't.foo'
,
$this
->
_type
->
convertToDatabaseValueSQL
(
't.foo'
,
$this
->
_platform
));
$this
->
assertEquals
(
't.foo'
,
$this
->
_type
->
convertToPHPValueSQL
(
't.foo'
,
$this
->
_platform
));
}
}
}
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