我有三张桌子
//1
CREATE TABLE `client_domain` (
`client_id` int(10) unsigned NOT NULL,
`domain_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`client_id`,`domain_id`),
KEY `FK_client_domains_domain` (`domain_id`),
CONSTRAINT `FK_client_domain` FOREIGN KEY (`domain_id`) REFERENCES `domain` (`id`) ON DELETE CASCADE,
CONSTRAINT `FK_client_domains_client` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf-8;
//2
CREATE TABLE `client` (
`id` int(10) unsigned NOT NULL,
`name` varchar(50) NOT NULL,
`notes` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf-8;
//3
CREATE TABLE `domain` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`domain_name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `IX_domain` (`domain_name`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf-8;
一切正常但是,当我尝试使用以下方法从client_domain表中删除记录时
$del = new ClientDom(array('db' => $this->_adapter));
$where[] = $del->getAdapter()->quoteInto('client_id = ?', $client);
$where[] = $del->getAdapter()->quoteInto('domain_id = ?', $domain);
$result = $del->delete($where)->toArray(); Idelete record but with an error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'client_id' in 'where clause'...
出了什么问题......如果我'fetchAll($ where)'也一样,但插入所有工作正常。
答案 0 :(得分:2)
通过以下方式解决: $ del->删除(阵列( 'client_id =?' => $客户端, 'domain_id =?' => $域 )); 不知道为什么,但是通过$哪里不行......如果有人知道为什么......请在这里写一下:)