Gab*_*Kid 10 php symfony doctrine-orm
image我有以下数据库结构
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
Run Code Online (Sandbox Code Playgroud)
如果我想一次查找几个项目,检查列是否存在,会发生什么
$dummy = findOneBy('voterid'=>1,'imageid'=>2,action=>"upvote");
if($dummy)
{
//column exists!
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?
Lau*_* W. 23
请参阅数据库和学说
如果要检索产品,关于某些属性,您只需将该方法findOneBy与作为参数的数组一起使用:
$product = $repository->findOneBy(array('name' => 'foo', 'price' => 19.99));
Run Code Online (Sandbox Code Playgroud)
您必须将所有值作为数组传递,如下所示:
$dummy = $this->getDoctrine()->getRepository("AcmeDemoBundle:User")->findOneBy(array(
'voterid'=>1,
'imageid'=>2,
'action'=>'upvote',
));
if($dummy)
{
//column exists!
}
Run Code Online (Sandbox Code Playgroud)
其中数组的键是列名,值是该列中的值。
注意:AcmeDemoBundle:User- 是您的实体
| 归档时间: |
|
| 查看次数: |
16110 次 |
| 最近记录: |