Reputation: 887
image I have the following database structure
class voters
{
protected $voterid;
protected $imageid;
protected $action;
}
// $voterid = is the current voter
// $imageid = is the id of the voted image
// $action = is upvote/downvote,delete
what happens if I want to look for several items at once, to check if a column exists, something like
$dummy = findOneBy('voterid'=>1,'imageid'=>2,action=>"upvote");
if($dummy)
{
//column exists!
}
Is this possible?
Upvotes: 13
Views: 24459
Reputation: 12306
You must pass all values as array like this:
$dummy = $this->getDoctrine()->getRepository("AcmeDemoBundle:User")->findOneBy(array(
'voterid'=>1,
'imageid'=>2,
'action'=>'upvote',
));
if($dummy)
{
//column exists!
}
Where key of array is a column name, value is a value in this column.
NOTE: AcmeDemoBundle:User
- is your entity
Upvotes: 5
Reputation: 3783
If you want to retrieve a product, regarding some properties, you just have to use the method findOneBy
with as parameters an array :
$product = $repository->findOneBy(array('name' => 'foo', 'price' => 19.99));
Upvotes: 29