简体   繁体   English

Zend Framework DB删除方法去除值

[英]Zend Framework DB delete method strips values

Im trying to delete record from database depending where conditions. 我试图根据条件从数据库中删除记录。 The query is pretty simple, but still Im getting strange results. 该查询非常简单,但是我仍然得到奇怪的结果。 What Im trying to do in ZF: 我想在ZF中做什么:

$where = array(
               $db->quoteInto('name = ?', $name),
               $db->quoteInto('surname = ?', $surname)
         );

$db->delete('users', $where);

While trying to debug Im getting: 在尝试调试即时消息时:

DELETE FROM `users` WHERE (name = 'John') AND (surname = 'Johnson')

What is correct and working SQL statement. 什么是正确且有效的SQL语句。 But later my values are getting stripped, so Im getting query like this: 但是后来我的值被剥夺了,所以我得到这样的查询:

DELETE FROM `users` WHERE (name = ) AND (surname = )

Depending debug results this happens in Zend_Db_Statement class (Statement.php), _stripQuoted method. 根据调试结果,这会在Zend_Db_Statement类(Statement.php) _stripQuoted方法中发生。

So finally as a result instead of one record deleted Im getting whole table cleared. 因此,最终结果是删除了一条表,而不是删除一条记录。

I've red the documentation and also Google'd for examples which are pretty much close to my situation. 我已将文档改写成红色,也对Google改写了一些与我的情况非常接近的示例。 So Im not getting what is wrong with that? 所以我不明白这是怎么回事?

Zend Framework version: 1.12 Zend Framework版本:1.12

Any ideas? 有任何想法吗?

The second parameter for delete should be a string. delete的第二个参数应为字符串。 So I think you want: 所以我想你想要:

$where = $db->quoteInto('name = ?', $name).' AND '.$db->quoteInto('surname = ?', $surname);    
$db->delete('users', $where);

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

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