SagarPPanchal
SagarPPanchal

Reputation: 10121

Delete query in zend framework 2

I can retrieve data easily from this, but while I tried from delete it deletes all the data of my table, what's going wrong in this?

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

Upvotes: 1

Views: 4220

Answers (1)

Mubo
Mubo

Reputation: 1070

I think the problem comes from the id.

Try this:-

<?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;
?>

Upvotes: 2

Related Questions