Symfony2,Doctrine,以“findXxx”方法名称加下划线

时间:2013-02-06 23:51:51

标签: symfony methods doctrine

简单的例子,我们有

/**
 * @ORM\Column(name="api_keyID", type="integer", nullable=false)
 */
private $api_keyID;

  /**
 * @return integer 
 */
public function getApi_keyID()
{
    return $this->api_keyID;
}

/**
 * @param integer $api_keyID
 * @return object
 */
public function setApi_keyID($data)
{
    $this->api_keyID = $data;

    return $this;
}

查看方法名称和列名称。当我尝试

//...
   ->findOneByApi_keyID($some);

我收到了像

这样的错误
Entity 'entity\path' has no field 'apiKeyID'. You can therefore not call 'findOneByApi_keyID' on the entities' repository 

所以教义\ symfony吃下划线? О.о我不能在列名中使用它?

1 个答案:

答案 0 :(得分:3)

是出路

$repository->findBy(array('is_enabled' => true));

在这里成立

Magic Doctrine2 finders when field has underscore?