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?
See Databases and Doctrine
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));
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With