Php 按降序排序表记录-symfony
我在数据库中有一个记录表,其中最后插入的记录是记录表行中的最后一个记录。在我的symfony应用程序中,我有一个从数据库获取数据的代码段,但是当结果被迭代时,最后插入的记录是视图中的最后一条记录。下面是片段 已编辑Php 按降序排序表记录-symfony,php,mysql,symfony,Php,Mysql,Symfony,我在数据库中有一个记录表,其中最后插入的记录是记录表行中的最后一个记录。在我的symfony应用程序中,我有一个从数据库获取数据的代码段,但是当结果被迭代时,最后插入的记录是视图中的最后一条记录。下面是片段 已编辑 $restresults = $this->getDoctrine()->getRepository('myBundle:Images')->findAll(); 如何按降序对上述条令片段进行排序,最后插入的将成为第一条记录 第二个参数用于订单: $message
$restresults = $this->getDoctrine()->getRepository('myBundle:Images')->findAll();
如何按降序对上述条令片段进行排序,最后插入的将成为第一条记录 第二个参数用于订单:
$messages = $em->getRepository("myBundle:Comments")->findBy(
array(
"imagefk" => $image
),
array('id' => 'DESC')
);
第二个参数用于订单:
$messages = $em->getRepository("myBundle:Comments")->findBy(
array(
"imagefk" => $image
),
array('id' => 'DESC')
);
假设您有id列
$restresults = $this->getDoctrine()->getRepository('myBundle:Images')->findBy([], ['id' => 'DESC']);
假设您有id列
$restresults = $this->getDoctrine()->getRepository('myBundle:Images')->findBy([], ['id' => 'DESC']);