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
e20c213a
Commit
e20c213a
authored
Sep 06, 2007
by
mahono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored Table->find()
parent
814223bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
27 deletions
+9
-27
Table.php
lib/Doctrine/Table.php
+9
-27
No files found.
lib/Doctrine/Table.php
View file @
e20c213a
...
@@ -827,7 +827,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
...
@@ -827,7 +827,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/
*/
public
function
hasPrimaryKey
(
$key
)
public
function
hasPrimaryKey
(
$key
)
{
{
return
in_array
(
$key
,
$this
->
primaryKeys
);
return
in_array
(
$key
,
$this
->
primaryKeys
);
}
}
/**
/**
* @return Doctrine_Connection
* @return Doctrine_Connection
...
@@ -853,38 +853,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
...
@@ -853,38 +853,20 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* finds a record by its identifier
* finds a record by its identifier
*
*
* @param $id database row id
* @param $id database row id
* @param int $hydrationMode Doctrine::
FETCH_ARRAY or Doctrine::FETCH
_RECORD
* @param int $hydrationMode Doctrine::
HYDRATE_ARRAY or Doctrine::HYDRATE
_RECORD
* @return
Doctrine_Record|false a record for given database identifier
* @return
mixed Array or Doctrine_Record or false if no result
*/
*/
public
function
find
(
$id
,
$hydrationMode
=
null
)
public
function
find
(
$id
,
$hydrationMode
=
null
)
{
{
if
(
$hydrationMode
===
null
)
{
if
(
is_null
(
$id
)
)
{
$hydrationMode
=
Doctrine
::
FETCH_RECORD
;
return
false
;
}
}
if
(
$id
!==
null
)
{
if
(
!
is_array
(
$id
))
{
$id
=
array
(
$id
);
}
else
{
$id
=
array_values
(
$id
);
}
$records
=
Doctrine_Query
::
create
()
$id
=
is_array
(
$id
)
?
array_values
(
$id
)
:
array
(
$id
);
->
from
(
$this
->
getComponentName
())
->
where
(
implode
(
' = ? AND '
,
$this
->
primaryKeys
)
.
' = ?'
)
->
execute
(
$id
,
$hydrationMode
);
if
(
count
(
$records
)
===
0
)
{
return
$this
->
createQuery
()
return
false
;
->
where
(
implode
(
' = ? AND '
,
$this
->
primaryKeys
)
.
' = ?'
)
}
->
fetchOne
(
$id
,
$hydrationMode
);
switch
(
$hydrationMode
)
{
case
Doctrine
::
FETCH_RECORD
:
return
$records
->
getFirst
();
case
Doctrine
::
FETCH_ARRAY
:
return
array_shift
(
$records
);
}
}
return
false
;
}
}
/**
/**
* applyInheritance
* applyInheritance
...
...
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