title: Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0._firstName' in 'field list'
body: <p>I have this module web application that is zend framework 1.12 into doctrine 2 (I just have to have it like this), right now I'm trying to get data from my database and just echo json_encode it when I hit the correct url which is url/api/people (which will return all the people). </p>
  
  <p>For some reason, I having this error that tells me t0._firstName as a column, but I know it isn't a column at all. I do use _firstName as a variable within my controller. </p>
  
  <p>-----stacktrace -----</p>
  
  <pre><code>#0 /var/www/app/library/Doctrine/DBAL/Connection.php(633): PDO-&gt;query('SELECT t0.id AS...')
  #1 /var/www/app/library/Doctrine/ORM/Persisters/BasicEntityPersister.php(727): Doctrine\DBAL\Connection-&gt;executeQuery('SELECT t0.id AS...', Array, Array)
  #2 /var/www/app/library/Doctrine/ORM/EntityRepository.php(179): Doctrine\ORM\Persisters\BasicEntityPersister-&gt;loadAll(Array, NULL, NULL, NULL)
  #3 /var/www/app/library/Doctrine/ORM/EntityRepository.php(165): Doctrine\ORM\EntityRepository-&gt;findBy(Array)
  #4 /var/www/app/application/modules/api/controllers/PeopleController.php(19): Doctrine\ORM\EntityRepository-&gt;findAll()
  #5 /var/www/app/library/Zend/Controller/Action.php(516): API_PeopleController-&gt;indexAction()
  #6 /var/www/app/library/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action-&gt;dispatch('indexAction')
  #7 /var/www/app/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard-&gt;dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
  #8 /var/www/app/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front-&gt;dispatch()
  #9 /var/www/app/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap-&gt;run()
  #10 /var/www/app/public/index.php(79): Zend_Application-&gt;run()
  #11 {main}
  </code></pre>
  
  <p>-----PeopleController-----</p>
  
  <pre><code>    &lt;?php
  
  use Doctrine\ORM;
  use API\Entity;
  
  class API_PeopleController extends Ia_Controller_Action_Abstract
  {
    public function indexAction()
    {
        if($this-&gt;getRequest()-&gt;isGet())
        {
          //access class
          $peopleClass = new API\Entity\People;
          //get entityManager
          $em = $peopleClass-&gt;getEntityManager();
          //get repo
          $peopleRepo = $em-&gt;getRepository('API\Entity\People');
          //use function from repo
          $people = $peopleRepo-&gt;findAll();
          foreach ($people as $obj)
          {
            echo $people;
          }
          //try to display all objects.
          /*
          foreach($people as $obj)
          {
            $resultArray[] = 
            [
              'id'         =&gt; $obj-&gt;id,
              'firstname'  =&gt; $obj-&gt;firstname,
              'lastname'   =&gt; $obj-&gt;lastname,
              "food"       =&gt; $obj-&gt;food
            ];
          }
          echo json_encode($resultArray, JSON_PRETTY_PRINT);
          */
  
  
          //$peopleMapper = new API_Model_PeopleMapper();
          //$this-&gt;view-&gt;entries = $peopleMapper-&gt;fetchAll();
        }
        else if($this-&gt;getRequest()-&gt;isPost())
        {
            $request = $this-&gt;getRequest();
            $getPeopleValues = $request-&gt;getPost();
            $people = new API_Model_People();
  
            $firstName = $getPeopleValues['firstName'];
            $lastName = $getPeopleValues['lastName'];
            $favFood = $getPeopleValues['favoriteFood'];
  
            if(empty($firstName) || empty($lastName) || empty($favFood))
            {
              throw new Exception("Please fill out all inputs", 1);
            }
  
            $people   -&gt;setFirstName($firstName)
                      -&gt;setLastName($lastName)
                      -&gt;setFavoriteFood($favFood);
            $peopleMapper = new API_Model_PeopleMapper();
            $peopleMapper-&gt;save($people);
        }
        else
        {
          throw new Exception("Error: Get/Post didn't work and something went really wrong", 1);
        }
    }
  
    public function getAction()
    {
        $people = new API_Model_People();
        $peopleMapper = new API_Model_PeopleMapper();
        $request = $this-&gt;getRequest();
        $id = $request-&gt;getParam('peopleId');
        $this-&gt;view-&gt;entries = $peopleMapper-&gt;getPeopleVisits($id);
    }
  }
  
  ?&gt;
  </code></pre>
  
  <p>-----People.php-----</p>
  
  <pre><code>    &lt;?php
  
  namespace API\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\ORM\EntityRepository;
  /**
  *
  * @ORM\Table(name="People")
  * @ORM\HasLifecycleCallbacks
  * @ORM\Entity(repositoryClass="API\Entity\PeopleRepository")
  * @author Paul Chu &lt;paulchu756@gmail.com&gt;
  */
  class People
  {
      /**
      *
      * @var integer $id
      * @ORM\Column(name="id", type="integer", nullable=false)
      * @ORM\Id
      * @ORM\GeneratedValue(strategy="IDENTITY")
      */
      protected $_id;
  
      /**
      *
      * @var string
      * @ORM\Column(name="firstname", type="string", length=60, nullable=false)
      */
      protected $_firstName;
  
      /**
      *
      * @var string
      * @ORM\Column(name="lastname", type="string", length=60, nullable=false)
      */
      protected $_lastName;
  
      /**
      *
      * @var string
      * @ORM\Column(name="food", type="string", length=60, nullable=false)
      */
      protected $_favoriteFood;
  
  
      public function setId($id)
      {
          $this-&gt;_id = (int) $id;
          return $this;
      }
      public function getId()
      {
          return $this-&gt;_id;
      }
  
      public function setFirstName($firstName)
      {
          $this-&gt;_firstName = (string) $firstName;
          return $this;
      }
      public function getFirstName()
      {
          return $this-&gt;_firstName;
      }
  
      public function setLastName($lastName)
      {
          $this-&gt;_lastName = (string) $lastName;
          return $this;
      }
      public function getLastName()
      {
          return $this-&gt;_lastName;
      }
  
      public function setFavoriteFood($favoriteFood)
      {
          $this-&gt;_favoriteFood = (string) $favoriteFood;
          return $this;
      }
      public function getFavoriteFood()
      {
          return $this-&gt;_favoriteFood;
      }
  
  
      public function __construct(array $options = null)
      {
          if(is_array($options))
          {
              $this-&gt;setOptions($options);
          }
      }
  
      public function setOptions(array $options)
      {
          $methods = get_class_methods($this);
          foreach($options as $key =&gt; $value)
          {
              $method = 'set' . ucfirst($key);
              if(in_array($method, $methods))
              {
                  $this-&gt;$method($value);
              }
          }
          return $this;
      }
  
      /**
      *
      * \Doctrine\Entity\Manager
      */
      public $em = null;
  
      /**
      * Get Doctrine Entity Manager
      * @return \Doctrine\Entity\Manager
      */
      public function getEntityManager() {
          if($this-&gt;em===null){
              $dc = \Zend_Registry::get('doctrine');
              $this-&gt;em = $dc-&gt;getEntityManager();
          }
          return $this-&gt;em;
      }
  
      /**
      * Magic getter to expose protected properties.
      *
      * @param string $property
      * @return mixed
      */
      public function __get($property) {
          return $this-&gt;$property;
      }
  
      /**
      * Magic setter to save protected properties.
      *
      * @param string $property
      * @param mixed $value
      */
      public function __set($property, $value) {
          $this-&gt;$property = $value;
      }
  
      /**
      * Convert the object to an array.
      *
      * @return array
      */
      public function toArray() {
          $vars = get_object_vars($this);
          return $vars;
      }
  
      /**
      * Create an entity with the given data
      *
      * @param array $data
      * @return object
      */
      public function createEntity(array $data)
      {
          $metadata = $this-&gt;getEntityManager()-&gt;getClassMetadata(get_class($this));
          if(isset($data['id'])){
              $metadata-&gt;setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
          }
          $entity = $metadata-&gt;newInstance();
          return $this-&gt;updateEntity($entity,$data);
      }
  
      /**
      * Update an entity with the given data
      *
      * @param array $data
      * @return object
      */
      public function updateEntity($entity, array $data)
      {
          $metadata = $this-&gt;getEntityManager()-&gt;getClassMetadata(get_class($this));
          foreach($data as $property =&gt; $value){
              if(!$metadata-&gt;reflClass-&gt;hasProperty($property))
                  continue;
              $metadata-&gt;setFieldValue($entity, $property, $value);
          }
          return $entity;
      }
  
      /** @ORM\PrePersist */
      public function prePersist()
      {
          $this-&gt;created_at = new \DateTime;
          $this-&gt;updated_at = new \DateTime;
      }
  
      /** @ORM\PreUpdate */
      public function preUpdate()
      {
          $this-&gt;updated_at = new \DateTime;
      }
  
  }
  </code></pre>
  
  <p>------init.php(database)------</p>
  
  <pre><code>    &lt;?php
  //zf configure db-adapter "adapter=PDO_MYSQL&amp;dbname=[myDB]&amp;host=[localhost]&amp;username=[root]&amp;password=[root]" -s development
  // Define variables.
  $host = "localhost";
  $user = "root";
  $password = "root";
  $database = "myDB";
  
  //Create connection
  $connection = mysqli_connect($host, $user, $password);
  // Check connection
  if(!$connection){
  die("Could not connect: " . mysqli_connect_error());}
  else{
      echo "Connection successfully \n";
  }
  
  // Drop database
  /*
  $dropDB = "DROP DATABASE myDB";
  // Check drop database
  if($connection-&gt;query($dropDB) === TRUE){
      echo "Database myDB was successfully dropped \n";
  } else {
      echo "Error dropping database: \n" . $connection-&gt;error;
  }
  */
  
  //Create Database called "myDB"
  $db = "CREATE DATABASE IF NOT EXISTS myDB";
  //Check Datebase
  if($connection-&gt;query($db) === TRUE){
      echo "Database created successfully \n";
  } else {
      echo "Error creating database: \n" . $connection-&gt;error;
  }
  
  // Select Database
  $connection-&gt;select_db($database);
  
  // Drop Visits table;
  $dropVisitsTable = "DROP TABLE Visits";
  if($connection-&gt;query($dropVisitsTable) === TRUE){
      echo "Visits Table was successfully dropped \n";
  } else {
      echo "Error dropping visits table: " . $connection-&gt;error . "\n";
  }
  
  // Drop People table;
  $dropPeopleTable = "DROP TABLE People";
  if($connection-&gt;query($dropPeopleTable) === TRUE){
      echo "People Table was successfully dropped \n";
  } else {
      echo "Error dropping people table: " . $connection-&gt;error . "\n";
  }
  
  // Drop States table;
  $dropStatesTable = "DROP TABLE States";
  if($connection-&gt;query($dropStatesTable) === TRUE){
      echo "States Table was successfully dropped \n";
  } else {
      echo "Error dropping states table: " . $connection-&gt;error . "\n";
  }
  
  // Create People Table
  $peopleTable = "CREATE TABLE IF NOT EXISTS People
  (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  firstname varchar(40) NOT NULL,
  lastname varchar(40) NOT NULL,
  food varchar(40) NOT NULL
  )";
  
  //Create States Table
  $statesTable = "CREATE TABLE IF NOT EXISTS States
  (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  stateabb varchar(2) NOT NULL,
  statename varchar(40) NOT NULL
  )";
  
  // Create Visit Table
  $visitTable = "CREATE TABLE IF NOT EXISTS Visits
  (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  p_id INT(40) NOT NULL,
  s_id INT(40) NOT NULL,
  FOREIGN KEY (p_id) REFERENCES People(id),
  FOREIGN KEY (s_id) REFERENCES States(id),
  date_visited varchar(40) NOT NULL
  )";
  
  //Check States Table
  if($connection-&gt;query($statesTable) === TRUE)
  {
      echo "States Table created successfully \n";
  }
  else
  {
      echo "States Table wasn't created \n" . $connection-&gt;error;
  }
  //Check People Table
  if($connection-&gt;query($peopleTable) === TRUE)
  {
      echo "People Table created successfully \n";
  }
  else
  {
      echo "People Table wasn't created \n" . $connection-&gt;error;
  }
  //Check Visit Table
  if($connection-&gt;query($visitTable) === TRUE)
  {
      echo "Visit Table created successfully \n";
  }
  else
  {
      echo "Visit Table wasn't created \n" . $connection-&gt;error;
  }
  
  // Insert data into states table
  $insertData = " INSERT INTO States (stateabb, statename)
                  VALUES ('LA', 'Louisiana');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('FL', 'Florida');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('TX', 'Texas');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('NM', 'New Mexico');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('ID', 'Idaho');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('IA', 'Iowa');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('ME', 'Maine');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('NV', 'Nevada');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('NY', 'New York');";
  $insertData .= "INSERT INTO States (stateabb, statename)
                  VALUES ('UT', 'Utah');";
  
  // Insert data into people table
  $insertData .= "INSERT INTO People (firstname, lastname, food)
                  VALUES ('Paul', 'Chu', 'Rice');";
  $insertData .= "INSERT INTO People (firstname, lastname, food)
                  VALUES ('Chui', 'Chu', 'Steak');";
  $insertData .= "INSERT INTO People (firstname, lastname, food)
                  VALUES ('Pandalord', 'Chu', 'Cookies');";
  $insertData .= "INSERT INTO People (firstname, lastname, food)
                  VALUES ('LordBabyPanda', 'Chu', 'Milk');";
  
  // Insert data into Visits table
  $insertData .= "INSERT INTO Visits (p_id, s_id, date_visited)
                  VALUES ('1', '1', '1994/07/14');";
  $insertData .= "INSERT INTO Visits (p_id, s_id, date_visited)
                  VALUES ('1', '2', '1994/07/14');";
  $insertData .= "INSERT INTO Visits (p_id, s_id, date_visited)
                  VALUES ('2', '10', '1994/07/14');";
  $insertData .= "INSERT INTO Visits (p_id, s_id, date_visited)
                  VALUES ('3', '9', '1994/07/14');";
  $insertData .= "INSERT INTO Visits (p_id, s_id, date_visited)
                  VALUES ('4', '7', '1994/07/14');";
  
  // Check stateData in table
  if($connection-&gt;multi_query($insertData) === TRUE)
  {
      $lastID = $connection-&gt;insert_id;
      echo "insertData create successfully. Last inserted ID is: " . $lastID . "\n";
  }
  else
  {
      echo "Error: \n" . $connection-&gt;error;
  }
  //Close Connection
  $connection-&gt;close();
  ?&gt;
  </code></pre>