开发者

Zend Table Relationship with Primary Composite Key - delete record from table

I have three tables

//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`),
  CO开发者_StackOverflow中文版NSTRAINT `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;

All work fine but, when I'm trying to delete record from client_domain table using:

$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'...

What is wrong... Also the same thing if I 'fetchAll($where)' but on insert all work fine.


Resolved via: $del->delete(array( 'client_id = ?' => $client, 'domain_id = ?' => $domain )); Don't know why but via $where it's not works... If some one know why... please write it here :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜