考虑以下代码形式文档
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,是否可以通过单个操作(不需要迭代)删除结果集
From 'Phalcon'Mvc'Model'Resultset delete()
删除结果集中的所有记录。
$robots = Robots::find("type='mechanical'");
if($robots->delete()){
echo "The robots were deleted successfully!";
}