I want to convert my sql row to doctrine object.
SELECT * FROM t_download GROUP BY download_yt_id ORDER BY download_id DESC LIMIT 50
I have maked that but that doesn't work :
$Download = new Download();
$em = $this->getDoctrine()->getManager();
$query = $em->createQueryBuilder();
$query
->select('distinct :id')
->from('DimiYvmBundle:Download', 'd')
->orderBy(':id', 'DESC')
->setParameter('id', $Download->getId());
$query->setMaxResults(50);
$lastdl = $query->getQuery()->getResult();
My Entity Download with getter and setters:
namespace Dimi\YvmBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
class Download
{
private $id;
private $ytId;
private $date;
private $title;
public function getId()
{
return $this->id;
}
public function setYtId($ytId)
{
$this->ytId = $ytId;
return $this;
}
public function getYtId()
{
return $this->ytId;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function getTitle()
{
return $this->title;
}
public function setDate($date)
{
$this->date = $date;
return $this;
}
public function getDate()
{
return $this->date;
}
public function getLastDownload()
{
// SELECT * FROM t_download GROUP BY download_yt_id ORDER BY download_id DESC LIMIT 50
}
}
I would like to include in my model my getLastDownload method. Do you know how I can do that ?
Thanks you all for your helping. Best regards,