简体   繁体   English

Zend Db表delete()无法正常工作

[英]Zend Db Table delete() not working properly

I have the following code: 我有以下代码:

$time = 60 * 60 * 24 * 3;

$usersTable = new Application_Model_Db_Users();

$where = 'active = false AND registration_time < ' . time() - $time;
$usersTable->delete($where);

But when it is run it deletes all the rows in the table, where as when I run 但是当它运行时,它将删除表中的所有行,就像我运行时一样

DELETE FROM users
WHERE active = false
AND registration_time < 1290500000

Only the ones that match the criteria are deleted. 只有符合条件的才被删除。 What is the problem? 问题是什么?

您只需要用括号将其包装起来,这样time()-$ time可以正确计算。

$where = 'active = false AND registration_time < ' . (time() - $time);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM