在 Zend 框架中为后续编写删除查询 [英] write delete query for following in zend framework
问题描述
我的 MySQL 数据库表中出现重复行的情况
所以我得到了这个
I am having a situation in my MySQL database table of row repeating
So I got this
DELETE from table1
USING table1, table1 as vtable
WHERE (NOT table1.ID=vtable.ID)
AND (table1.field_name=vtable.field_name)
其中table1
是表,vtable
是虚拟表
我应该如何在 Zend Framework
推荐答案
Zend_Db_Select
支持 USING
子句,但我认为 Zend_Db_Adapter
delete()
方法.
Zend_Db_Select
supports the USING
clause, but I think it's not supported by the Zend_Db_Adapter
delete()
method.
一个可能的替代方法是将 SQL 表达式直接传递给连接(如果您使用的是 pdo_mysql
适配器,它将是一个 PDO 对象):
A possible alternative would be passing the SQL expression directly to the connection (if you are using the pdo_mysql
adapter, it will be a PDO object):
$db->getConnection()->exec($sqlExpression);
$db->getConnection()->exec($sqlExpression);
(重要:确保正确引用 SQL 语句中的所有标识符和值,Zend_Db_Adapter
有一些 关于此的大量文档).
(IMPORTANT: Make sure you quote properly all the identifiers and values in the SQL sentence, Zend_Db_Adapter
has some extensive documentation about this).
这篇关于在 Zend 框架中为后续编写删除查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!