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
6b4e0328
Commit
6b4e0328
authored
Nov 01, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Doctrine_Connection::queryOne()
parent
ad595dd8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
Connection.php
lib/Doctrine/Connection.php
+41
-1
No files found.
lib/Doctrine/Connection.php
View file @
6b4e0328
...
...
@@ -150,6 +150,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
*/
public
function
driverName
(
$name
)
{
}
/**
* supports
*
* @param string $feature the name of the feature
* @return boolean whether or not this drivers supports given feature
*/
public
function
supports
(
$feature
)
{
return
(
isset
(
$this
->
supported
[
$feature
])
&&
$this
->
supported
[
$feature
]
===
'emulated'
||
$this
->
supported
[
$feature
]);
}
/**
* returns a datadict object
*
...
...
@@ -316,6 +327,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* query
* queries the database using Doctrine Query Language
* returns a collection of Doctrine_Record objects
*
* <code>
* $users = $conn->query('SELECT u.* FROM User u');
...
...
@@ -333,6 +345,34 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return
$parser
->
query
(
$query
,
$params
);
}
/**
* query
* queries the database using Doctrine Query Language and returns
* the first record found
*
* <code>
* $user = $conn->queryOne('SELECT u.* FROM User u WHERE u.id = ?', array(1));
*
* $user = $conn->queryOne('SELECT u.* FROM User u WHERE u.name LIKE ? AND u.password = ?',
* array('someone', 'password')
* );
* </code>
*
* @param string $query DQL query
* @param array $params query parameters
* @see Doctrine_Query
* @return Doctrine_Record|false Doctrine_Record object on success,
* boolean false on failure
*/
public
function
queryOne
(
$query
,
array
$params
=
array
())
{
$parser
=
new
Doctrine_Query
(
$this
);
$coll
=
$parser
->
query
(
$query
,
$params
);
if
(
!
$coll
->
contains
(
0
))
return
false
;
return
$coll
[
0
];
}
/**
* queries the database with limit and offset
* added to the query and returns a PDOStatement object
...
...
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