考虑以下代码表单文档
foreach (Robots::find("type='mechanical'") as $robot) {
if ($robot->delete() == false) {
echo "Sorry, we can't delete the robot right now: \n";
foreach ($robot->getMessages() as $message) {
echo $message, "\n";
}
} else {
echo "The robot was deleted successfully!";
}
}
使用Phalcon,是否可以使用单个操作删除结果集(无需迭代)。
答案 0 :(得分:8)
从\Phalcon\Mvc\Model\Resultset delete()
删除结果集中的每条记录。
$robots = Robots::find("type='mechanical'");
if($robots->delete()){
echo "The robots were deleted successfully!";
}