2010-11-21 4 views
0

J'ai trois tablesZend Table Relations avec primaire composite clé - supprime l'enregistrement de la table

//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; 

Tous les travaux fins mais, quand je suis en train de supprimer l'enregistrement de la table de client_domain en utilisant:

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

Quel est le problème ... Aussi la même chose si je vais chercher ($ where) 'mais sur insérer tout fonctionne bien.

Répondre

2

résolu via: $ délé-> supprimer (array ( '? Client_id =' => $ client, '? Id_domaine =' => $ domain )); Je ne sais pas pourquoi mais via $ où ça ne marche pas ... Si quelqu'un sait pourquoi ... s'il vous plaît écrivez-le ici :)

Questions connexes