分贝:
here
控制器:
$comments = $commentRepo->getPaginationPost($recordsPerPage, $offset, $id);
dump($comments); exit;
储存库:
public function getPaginationPost($limit, $offset, $postId)
{
$qb = $this->createQueryBuilder('c')
->where('c.postId = :postId')
->setParameter('postId', $postId)
->andWhere('c.replyTo = 0')
->orderBy('c.dateAdded', 'DESC')
->setMaxResults($limit)
->setFirstResult($offset)
->getQuery();
return $qb->getArrayResult();
}
实体:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
class Comment
{
private $id;
private $content;
private $person;
嗯,转储的结果是完整的数据,除了列person(person_id)。你知道为什么会这样吗?“人”列与“关系”列是同一个对象,它们都有getter和setter。
从结果
dump()
:
ArticleController.php on line 183:
array:10 [
0 => array:5 [
"id" => 168
"content" => "ÐоÑо е"
"dateAdded" => DateTime {
+"date": "2019-01-09 11:02:35.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
"replyTo" => 0
"postId" => 8
]
1 => array:5 [
"id" => 167
"content" => "нееее лоÑооо"
"dateAdded" => DateTime {
+"date": "2019-01-08 16:07:09.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
"replyTo" => 0
"postId" => 8
]
]
...