2013-11-23 144 views
0

MySQL的使用Entity Manager從表格中選擇列的最大值的最簡單最簡單的方法是什麼?

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(); 
+0

初學者有用似乎是第一個? –

+0

[Semantical Error] line 0,col 11 near'pdate)as date1':Error:'pdate'is not defined.I m getting error: – bhuko

回答

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']."'"); 
相關問題