使用Entity Manager从表中选择列的最大值的最简单,最简单的方法是什么?

时间:2013-11-23 07:04:36

标签: php mysql entity-framework doctrine-orm zend-framework2

的MySQL

select max(PARAM_DATE) from access_param;

ZF2

$em = $this->getEntityManager();
$pp = $em->createQuery("select max(pdate) as date1 from Access\Entity\Param B");
$user2 = $pp->getResult();

$q =$em->createQuery"selectB.pdate,B.userid,B.pdate,B.password,B.uppercase,B.useridspecial,B.number from Access\Entity\Param B where B.pdate='".$user2."' " );
$user1 = $q->getResult();

1 个答案:

答案 0 :(得分:0)

最后我得到了输出,我认为它对初学者使用实体管理器很有用

$pp = $em->createQuery("select max(B.pdate) as date1 from Access\Entity\Param B");

$user2 = $pp->getResult();

foreach($user2 as $user2) { 
    $pdate=$user2['date1'];
}

$_POST['pdate']=$pdate; 
$q = $em->createQuery("SELECT 
                   B.pdate, B.userid, B.pdate, B.password, 
                   B.uppercase, B.useridspecial, B.number
                   FROM Access\Entity\Param B
                   WHERE B.pdate='".$_POST['pdate']."'");