2014-07-07 113 views
1

我可以很容易地從中檢索數據,但是當我嘗試從刪除它刪除我的表的所有數據,這是怎麼回事?在zend框架中刪除查詢2

$db = $this->serviceLocator->get('Zend\Db\Adapter\Adapter'); 
$sel = new Sql($db); 
$s=$sel->delete('milestone','goal_id='.$edit_id); 
echo $s->getSqlString(); 

回答

1

我覺得問題來自id。

試試這個: -

<?php 

     $db = $this->serviceLocator->get('Zend\Db\Adapter\Adapter'); 
     $sql = new Sql($db); 
     $delete = $sql->delete('milestone')->where("goal_id = $edit_id"); 
     //see the deleted entry  
     $deleteString = $sql->getSqlStringForSqlObject($delete); 
     echo $deleteString; 
?> 
+0

謝謝:),它的作品! – SagarPPanchal

+0

更好'$ delete = $ sql-> delete('milestone'); $ delete-> where-> equalTo('goal_id',$ edit_id);'這樣你就可以使用準備好的語句。 –