Почему Doctrine извлекает только последнюю запись в наборе результатов?

В настоящее время я использую Doctrine 1.2.2 с MySQL на сервере. Когда я пытаюсь получить набор результатов для нескольких элементов, используя режимы гидратации записи или отложенной загрузки, отображается только один элемент. Однако, когда я использую режим гидратации массива, я вижу все результаты. Последовательно, извлекается только последний элемент в наборе результатов.

Я неправильно понял API? Модель определена неправильно (она была сгенерирована автоматически). Разве это не должно быть так просто?

Прямо сейчас я запускаю свой отладчик и буду проходить через исходный код Doctrine.

// Model used:

<?php

/**
 * BaseEntryVote
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @property integer $contest_id
 * @property integer $vote_id
 * @property integer $entry_id
 * @property integer $subcategory_id
 * @property string $company
 * @property string $website
 * @property string $email
 * @property string $comments
 * @property integer $votes
 * 
 * @package    ##PACKAGE##
 * @subpackage ##SUBPACKAGE##
 * @author     ##NAME## <##EMAIL##>
 * @version    SVN: $Id: $
 */
abstract class BaseEntryVote extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('entry_vote');
        $this->hasColumn('contest_id', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => true,
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('vote_id', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             ));
        $this->hasColumn('entry_id', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'default' => '0',
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('subcategory_id', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'default' => '0',
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('company', 'string', 100, array(
             'type' => 'string',
             'length' => 100,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('website', 'string', 75, array(
             'type' => 'string',
             'length' => 75,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('email', 'string', 75, array(
             'type' => 'string',
             'length' => 75,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('comments', 'string', 255, array(
             'type' => 'string',
             'length' => 255,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('votes', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             ));
    }

    public function setUp()
    {
        parent::setUp();

    }
}


// Below is the code used to access the doctrine api

/*
Table entry_vote
================
contest_id, vote_id, entry_id, subcategory_id, company, website, email, comments, votes
----------------
contest_id   INT
vote_id      INT
entry_id     INT
subcategory_id INT
company      VARCHAR
website      VARCHAR
email        VARCHAR
comments     VARCHAR
votes        INT

Data in db:
'0', '1', '1', '0', 'Foo Bank', 'http://localhost/foo', 'bob@foo.com', NULL, '2'
'0', '0', '0', '0', 'TPS Corp', 'http://localhost/tps', 'bob@tps.com', NULL, '1'
*/

$result = Doctrine_Core::getTable('EntryVote')->findAll();

foreach ($result as $entry) {
   print $entry->company;
}

/* Here is the query that Doctrine is generating: */
SELECT e.contest_id AS e__contest_id, e.vote_id AS e__vote_id, 
e.entry_id AS e__entry_id, e.subcategory_id AS e__subcategory_id,
e.company AS e__company, e.website AS e__website,
e.email AS e__email, e.comments AS e__comments, e.votes AS e__votes
FROM entry_vote e WHERE (e.contest_id = ?)
1
задан Elijah 13 September 2010 в 19:59
поделиться