Ok, so i'm trying to delete multiple entries of a collection (carriers) based on their id which is passed to controller via GET method.
Basically what I do is get the ids and send them to a popup (view) that have a button which makes an ajax call to the action that deletes the entries based on ids (they're passed to this action via POST method).
after that, I use this action to delete them (which is not working):
public function removeCarrierAction()
{
$request = new Phalcon\Http\Request();
if($request->isPost() == true){
if($request->isAjax() == true){
//Get the ids that came into a string like "id1,id2,id3,..idn"
$ids = explode(",",$request->getPost(0));
//I've already tried with Carriers::findById($ids), but it didin't work either
$carriers = Carriers::find(["_id" => $ids]);
//delete all returned carriers
foreach($carriers as $carrier){
if($carrier->delete() == true){
echo print_r($ids);
}else{
echo "error";
}
}
}
}
}
It for some reason delete all the entries. Not only the based on the ids i've passed. Any idea of how to make it works propely?