delete() == fals-6ren">
gpt4 book ai didi

php - 如何使用 Phalcon ORM 删除结果集

转载 作者:行者123 更新时间:2023-12-02 06:56:33 24 4
gpt4 key购买 nike

考虑以下代码形式的文档

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,是否可以通过一次操作(无需迭代)删除结果集。

最佳答案

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

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

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

关于php - 如何使用 Phalcon ORM 删除结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30262726/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com