I am working on a doctrine 2 sandbox (Beta3) and trying to apply the Zend Framework coding convention to place the main underscore for private class members. When I request an address while its private members are NOT underlined, I return the object as expected. When I add underscores, regenerate and refill db, and then run the same query, I get the following error messages:
PHP Note: Undefined index: id in ... Doctrine / ORM / Internal / Hydration / AbstractHydrator.php on line 184 PHP Fatal error: Failed to throw "Doctrine \ DBAL \ DBALException" with the message "Unknown column type". in ... Doctrine / DBAL / DBALException.php: 81
DQL query:
$q = $em->createQuery('select u from Entities\Address u where u.id = ?1'); $q->setParameter(1, '1'); $address = $q->getSingleResult();
ZFed Address Class:
<?php namespace Entities; class Address { private $_id; private $_street; public function getId() { return $this->_id; } public function getStreet() { return $this->_street; } public function setStreet($street) { $this->_street = $street; } }
source share