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
aa349ecb
Commit
aa349ecb
authored
Dec 22, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
7b48189b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
10 deletions
+101
-10
Hydrate.php
lib/Doctrine/Hydrate.php
+9
-1
Query.php
lib/Doctrine/Query.php
+4
-0
From.php
lib/Doctrine/Query/From.php
+31
-2
Record.php
lib/Doctrine/Record.php
+1
-1
DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php
... (Doctrine Query Language) - GROUP BY, HAVING clauses.php
+1
-1
DQL (Doctrine Query Language) - Functional Expressions - String functions.php
...Language) - Functional Expressions - String functions.php
+55
-5
No files found.
lib/Doctrine/Hydrate.php
View file @
aa349ecb
...
...
@@ -321,6 +321,14 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
if
(
is_bool
(
$item
))
$item
=
(
int
)
$item
;
}
/**
* setParams
*
* @param array $params
*/
public
function
setParams
(
array
$params
=
array
())
{
$this
->
params
=
$params
;
}
/**
* execute
* executes the dql query and populates all collections
...
...
@@ -405,7 +413,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
if
(
$prev
[
$name
]
->
count
()
>
0
)
{
$record
=
$prev
[
$name
]
->
getLast
();
}
else
{
}
else
{
$record
=
new
$component
();
$prev
[
$name
]
->
add
(
$record
);
}
...
...
lib/Doctrine/Query.php
View file @
aa349ecb
...
...
@@ -224,6 +224,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
if
(
!
empty
(
$having
))
$q
.=
' HAVING '
.
implode
(
' AND '
,
$having
);
if
(
!
is_array
(
$params
))
$params
=
array
(
$params
);
$params
=
array_merge
(
$this
->
params
,
$params
);
$a
=
$this
->
getConnection
()
->
execute
(
$q
,
$params
)
->
fetch
(
PDO
::
FETCH_NUM
);
...
...
@@ -533,6 +536,7 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
switch
(
strtolower
(
$this
->
conn
->
getName
()))
{
case
'mysql'
:
// mysql doesn't support LIMIT in subqueries
$params
=
array_merge
(
$this
->
params
,
$params
);
$list
=
$this
->
conn
->
execute
(
$subquery
,
$params
)
->
fetchAll
(
PDO
::
FETCH_COLUMN
);
$subquery
=
implode
(
', '
,
$list
);
break
;
...
...
lib/Doctrine/Query/From.php
View file @
aa349ecb
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
Doctrine
::
autoload
(
"Doctrine_Query_Part"
);
/**
* Doctrine_Query_From
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class
Doctrine_Query_From
extends
Doctrine_Query_Part
{
/**
...
...
@@ -15,7 +44,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part {
$parts
=
Doctrine_Query
::
bracketExplode
(
$str
,
'JOIN'
);
$operator
=
false
;
switch
(
trim
(
$parts
[
0
]))
{
case
'INNER'
:
$operator
=
':'
;
...
...
lib/Doctrine/Record.php
View file @
aa349ecb
...
...
@@ -369,7 +369,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value
=
unserialize
(
$tmp
[
$name
]);
if
(
$value
===
false
)
throw
new
Doctrine_Record_Exception
(
"Unserialization of
$name
failed.
"
.
var_dump
(
substr
(
$tmp
[
$lower
],
0
,
30
)
.
"..."
,
true
)
);
throw
new
Doctrine_Record_Exception
(
"Unserialization of
$name
failed.
"
);
}
else
$value
=
$tmp
[
$name
];
...
...
manual/codes/DQL (Doctrine Query Language) - GROUP BY, HAVING clauses.php
View file @
aa349ecb
...
...
@@ -5,6 +5,6 @@
$users
=
$conn
->
query
(
"SELECT u.*, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id"
);
foreach
(
$users
as
$user
)
{
print
$user
->
name
.
' has '
.
$user
->
Phonenumber
->
getAggregateValue
(
'count'
)
.
' phonenumbers'
;
print
$user
->
name
.
' has '
.
$user
->
Phonenumber
[
0
]
->
count
.
' phonenumbers'
;
}
?>
manual/docs/DQL (Doctrine Query Language) - Functional Expressions - String functions.php
View file @
aa349ecb
<?php
?>
<ul>
<li
\
>
The
<i>
CONCAT
</i>
function returns a string that is a concatenation of its arguments.
<li
\
>
The
<i>
CONCAT
</i>
function returns a string that is a concatenation of its arguments. In the example above we
map the concatenation of users firstname and lastname to a value called name
<br
\
><br
\
>
<?php
renderCode
(
"<?php
\$
q = new Doctrine_Query();
\$
users =
\$
q->select('CONCAT(u.firstname, u.lastname) name')->from('User u')->execute();
foreach(
\$
users as
\$
user) {
// here 'name' is not a property of
\$
user,
// its a mapped function value
print
\$
user->name;
}
?>"
);
?>
<br
\
><br
\
>
<li
\
>
The second and third arguments of the
<i>
SUBSTRING
</i>
function denote the starting position and length of
the substring to be returned. These arguments are integers. The first position of a string is denoted by 1.
The
<i>
SUBSTRING
</i>
function returns a string.
<br
\
><br
\
>
The
<i>
SUBSTRING
</i>
function returns a string.
<br
\
><br
\
>
<?php
renderCode
(
"<?php
\$
q = new Doctrine_Query();
\$
users =
\$
q->select('u.name')->from('User u')->where(
\"
SUBSTRING(u.name, 0, 1) = 'z'
\"
)->execute();
foreach(
\$
users as
\$
user) {
print
\$
user->name;
}
?>"
);
?>
<br
\
><br
\
>
<li
\
>
The
<i>
TRIM
</i>
function trims the specified character from a string. If the character to be trimmed is not
specified, it is assumed to be space (or blank). The optional trim_character is a single-character string
literal or a character-valued input parameter (i.e., char or Character)[30]. If a trim specification is
not provided, BOTH is assumed. The
<i>
TRIM
</i>
function returns the trimmed string.
<br
\
><br
\
>
<br
\
><br
\
>
<?php
renderCode
(
"<?php
\$
q = new Doctrine_Query();
\$
users =
\$
q->select('u.name')->from('User u')->where(
\"
TRIM(u.name) = 'Someone'
\"
)->execute();
foreach(
\$
users as
\$
user) {
print
\$
user->name;
}
?>"
);
?>
<br
\
><br
\
>
<li
\
>
The
<i>
LOWER
</i>
and
<i>
UPPER
</i>
functions convert a string to lower and upper case, respectively. They return a
string.
<br
\
><br
\
>
<?php
renderCode
(
"<?php
\$
q = new Doctrine_Query();
\$
users =
\$
q->select('u.name')->from('User u')->where(
\"
LOWER(u.name) = 'someone'
\"
)->execute();
foreach(
\$
users as
\$
user) {
print
\$
user->name;
}
?>"
);
?>
<br
\
><br
\
>
<li
\
>
The
<i>
LOCATE
</i>
function returns the position of a given string within a string, starting the search at a specified
position. It returns the first position at which the string was found as an integer. The first argument
is the string to be located; the second argument is the string to be searched; the optional third argument
is an integer that represents the string position at which the search is started (by default, the beginning of
the string to be searched). The first position in a string is denoted by 1. If the string is not found, 0 is
returned.[31]
returned.
<br
\
><br
\
>
<li
\
>
The
<i>
LENGTH
</i>
function returns the length of the string in characters as an integer.
...
...
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