|
|||
|
Hi,
Relative newbie here...trying to figure out the best way to delete multiple records from a single table. the only way I've been able to get all the syntax to work is the function listed below here. I'm passing to it the database connection and an array of the id's to be deleted from a table called 'event'. Code:
public function DeleteMultiple($db, $aDeleteList)
{
$count = 0;
foreach ($aDeleteListas $value)
{
$where = $db->quoteInto('id = ?', $value);
$db->delete('event', $where);
$count++;
}
return $count;
}
Code:
$del_id_list = mysql_real_escape_string(implode(',', $_POST['checkbox']));
$sql = "DELETE FROM $tbl_name WHERE queueID IN ($del_id_list)";
Thanks! |
|
|||
|
Quote:
*Wouldn't let me post the code i guess for security reasons but check out the link below for how to execute quires directly. Zend Framework: Documentation
__________________
Bester News |
|
|||
|
Hmm, do you mean build a sql string dynamically, then execute it like-a dis?:
Code:
<?phprequire_once 'Zend/Db/Statement/Mysqli.php'; $sql = 'DELETE* FROM my_table WHERE id = ?'; $stmt = new Zend_Db_Statement_Mysqli($db, $sql); // and then run the execute() method...but... ...?> Code:
$sql = 'DELETE* FROM bugs WHERE reported_by = ? AND bug_status = ?'; Code:
$stmt->execute(array('goofy', 'FIXED'));
Code:
$del_id_list = implode(',', $_POST['checkbox'])); // create string comma separated id's
$stmt->execute(array($del_id_list);
Code:
$stmt->execute($del_id_list); Thanks so much! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|