我在 Doctrine 2 Repository 函数中有一个奇怪的错误
$query = $this->_em->createQuery('SELECT c FROM \Model\Entity\Cluster c
WHERE c.publisherid = :publisherid');
$query->setParameter("publisherid", (int)$publisher_id);
var_dump($query->getResult());
var_dump($query->getArrayResult());
而我们所拥有的
对象:
array (size=8)
0 =>
object(Model\Entity\Cluster)[**396**]
private 'psiteid' => int 215
private 'psiteclusterdate' =>
object(DateTime)[371]
public 'date' => string '**2011-12-20** 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
private 'publisherid' => int 276
private 'views' => int 14657
private 'clicks' => int 6220
...
1 =>
object(Model\Entity\Psitecluster)[**396**]
private 'psiteid' => int 215
private 'psiteclusterdate' =>
object(DateTime)[371]
public 'date' => string '**2011-12-20** 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
private 'publisherid' => int 276
private 'views' => int 14657
private 'clicks' => int 6220
...
键为 0-3 的行复制此对象 (396),其他行复制第二个对象。当我转储为数组时:
array (size=8)
0 =>
array (size=22)
'psiteid' => int 215
'psiteclusterdate' =>
object(DateTime)[367]
public 'date' => string '**2011-12-20** 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
'publisherid' => int 276
'views' => int 14657
'clicks' => int 6220
....
1 =>
array (size=22)
'psiteid' => int 215
'psiteclusterdate' =>
object(DateTime)[396]
public 'date' => string '2011-12-21 00:00:00' (length=19)
public 'timezone_type' => int 3
public 'timezone' => string 'Europe/Moscow' (length=13)
'publisherid' => int 276
'views' => int 10166
'clicks' => int 4028
所有行在数组中都不同。对象有什么问题?