如何使用Phalcon ORM删除结果集

时间:2015-05-15 14:58:02

标签: php orm phalcon

考虑以下代码表单文档

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,是否可以使用单个操作删除结果集(无需迭代)。

1 个答案:

答案 0 :(得分:8)

\Phalcon\Mvc\Model\Resultset delete()删除结果集中的每条记录。

$robots = Robots::find("type='mechanical'");

if($robots->delete()){
    echo "The robots were deleted successfully!";
}