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
9b524636
Commit
9b524636
authored
Sep 01, 2007
by
jackbravo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added FETCH_ARRAY support for table finder methods, fixes bug #397
parent
202d6686
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
15 deletions
+32
-15
Connection.php
lib/Doctrine/Connection.php
+3
-2
Query.php
lib/Doctrine/Query.php
+5
-4
Table.php
lib/Doctrine/Table.php
+24
-9
No files found.
lib/Doctrine/Connection.php
View file @
9b524636
...
...
@@ -677,14 +677,15 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*
* @param string $query DQL query
* @param array $params query parameters
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
* @see Doctrine_Query
* @return Doctrine_Collection Collection of Doctrine_Record objects
*/
public
function
query
(
$query
,
array
$params
=
array
()
)
public
function
query
(
$query
,
array
$params
=
array
()
,
$hydrationMode
=
null
)
{
$parser
=
new
Doctrine_Query
(
$this
);
return
$parser
->
query
(
$query
,
$params
);
return
$parser
->
query
(
$query
,
$params
,
$hydrationMode
);
}
/**
* prepare
...
...
lib/Doctrine/Query.php
View file @
9b524636
...
...
@@ -1522,14 +1522,15 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*
* @param string $query DQL query
* @param array $params prepared statement parameters
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
* @see Doctrine::FETCH_* constants
* @return mixed
*/
public
function
query
(
$query
,
$params
=
array
())
public
function
query
(
$query
,
$params
=
array
()
,
$hydrationMode
=
null
)
{
$this
->
parseQuery
(
$query
);
return
$this
->
execute
(
$params
);
return
$this
->
execute
(
$params
,
$hydrationMode
);
}
public
function
copy
(
Doctrine_Query
$query
=
null
)
...
...
lib/Doctrine/Table.php
View file @
9b524636
...
...
@@ -853,10 +853,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* finds a record by its identifier
*
* @param $id database row id
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
* @return Doctrine_Record|false a record for given database identifier
*/
public
function
find
(
$id
)
public
function
find
(
$id
,
$hydrationMode
=
null
)
{
if
(
$hydrationMode
===
null
)
{
$hydrationMode
=
Doctrine
::
FETCH_RECORD
;
}
if
(
$id
!==
null
)
{
if
(
!
is_array
(
$id
))
{
$id
=
array
(
$id
);
...
...
@@ -867,14 +871,23 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$records
=
Doctrine_Query
::
create
()
->
from
(
$this
->
getComponentName
())
->
where
(
implode
(
' = ? AND '
,
$this
->
primaryKeys
)
.
' = ?'
)
->
execute
(
$id
);
->
execute
(
$id
,
$hydrationMode
);
if
(
count
(
$records
)
===
0
)
{
return
false
;
}
switch
(
$hydrationMode
)
{
case
Doctrine
::
FETCH_RECORD
:
if
(
count
(
$records
)
>
0
)
{
return
$records
->
getFirst
();
}
case
Doctrine
::
FETCH_ARRAY
:
if
(
!
empty
(
$records
[
0
]))
{
return
$records
[
0
];
}
}
}
return
false
;
}
/**
...
...
@@ -898,12 +911,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* findAll
* returns a collection of records
*
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
* @return Doctrine_Collection
*/
public
function
findAll
()
public
function
findAll
(
$hydrationMode
=
null
)
{
$graph
=
new
Doctrine_Query
(
$this
->
conn
);
$users
=
$graph
->
query
(
'FROM '
.
$this
->
options
[
'name'
]);
$users
=
$graph
->
query
(
'FROM '
.
$this
->
options
[
'name'
]
,
array
(),
$hydrationMode
);
return
$users
;
}
/**
...
...
@@ -913,16 +927,17 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*
* @param string $dql DQL after WHERE clause
* @param array $params query parameters
* @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD
* @return Doctrine_Collection
*/
public
function
findBySql
(
$dql
,
array
$params
=
array
())
{
public
function
findBySql
(
$dql
,
array
$params
=
array
()
,
$hydrationMode
=
null
)
{
$q
=
new
Doctrine_Query
(
$this
->
conn
);
$users
=
$q
->
query
(
'FROM '
.
$this
->
options
[
'name'
]
.
' WHERE '
.
$dql
,
$params
);
$users
=
$q
->
query
(
'FROM '
.
$this
->
options
[
'name'
]
.
' WHERE '
.
$dql
,
$params
,
$hydrationMode
);
return
$users
;
}
public
function
findByDql
(
$dql
,
array
$params
=
array
())
{
return
$this
->
findBySql
(
$dql
,
$params
);
public
function
findByDql
(
$dql
,
array
$params
=
array
()
,
$hydrationMode
=
null
)
{
return
$this
->
findBySql
(
$dql
,
$params
,
$hydrationMode
);
}
/**
* clear
...
...
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