user1954544
user1954544

Reputation: 1687

Symfony2, Doctrine, underscore in "findXxx" method name

Simple example, we've got

/**
 * @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;
}

Look at method name and column name. When i try

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

I'm getting an error like

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

So doctrine\symfony eats underscore? О.о And i cannot use it in column name?

Upvotes: 0

Views: 845

Answers (1)

user1954544
user1954544

Reputation: 1687

is the way out

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

Founded here

Magic Doctrine2 finders when field has underscore?

Upvotes: 3

Related Questions