I am working through the doctrine 2 (Beta3) sandbox and trying to apply the Zend Framework coding convention of placing a leading underscore to private class members. When I query Address, while its private members are NOT underscored, i retrieve the object as expected. When I add the underscores, regenerate and repopulate the db, and then run the same query I get the following error messages:
PHP Notice: Undefined index: id in ... Doctrine/ORM/Internal/Hydration/AbstractHydrator.php on line 184 PHP Fatal error: Uncaught exception 'Doctrine\DBAL\DBALException' with message 'Unknown column type requested.' in ... Doctrine/DBAL/DBALException.php:81
The DQL query:
$q = $em->createQuery('select u from Entities\Address u where u.id = ?1');
$q->setParameter(1, '1');
$address = $q->getSingleResult();
The ZFed Address class:
<?php
namespace Entities;
/** @Entity @Table(name="addresses") */
class Address
{
/**
* @Id @Column(type="integer", length=11, name="id")
* @GeneratedValue(strategy="AUTO")
*/
private $_id;
/** @Column(type="string", length=255, name="street") */
private $_street;
public function getId()
{
return $this->_id;
}
public function getStreet()
{
return $this->_street;
}
public function setStreet($street)
{
$this->_street = $street;
}
}