我需要有关此代码的帮助:
$mdl = Doctrine_Query::create()
->update('Model_CoachsTownsLang ctl')
->set('ctl.Coachs_Users_id', '1')
->set('ctl.Towns_idTowns', '1')
->set('ctl.Langs_idLang', '2')
->set('ctl.title', $data['title'])
->set('ctl.active', $data['active'])
->set('ctl.description', $data['description'])
->set('ctl.modyfication', '1')
->set('ctl.modyfied_id', $userData['id'])
->set('ctl.permit', $data['permit'])
->where('ctl.Coachs_Users_id =?', $data['id'])
->execute();
ZFDebug输出错误:
Doctrine_Connection_Mysql_Exception:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;查看与MySQL服务器版本对应的手册,以便在'sdfg sdfg附近使用正确的语法,active = 1,description = ...
但我看看这段代码,我发现语法没有错误。我指望你的帮助。
Tabla为数据库添加了结构:
CREATE TABLE IF NOT EXISTS `intelektualnie`.`CoachsTownsLangs` (
`id` INT NOT NULL AUTO_INCREMENT ,
`Coachs_Users_id` INT NULL ,
`Towns_idTowns` INT NULL DEFAULT NULL ,
`Langs_idLang` INT NULL DEFAULT NULL ,
`title` TEXT NULL DEFAULT NULL ,
`description` TEXT NULL DEFAULT NULL ,
`active` TINYINT(1) NOT NULL DEFAULT 0 ,
`modyfication` TINYINT(1) NOT NULL DEFAULT 0 ,
`modyfied_id` INT NULL DEFAULT NULL ,
`permit` TINYINT(1) NOT NULL DEFAULT 1 ,
PRIMARY KEY (`id`) ,
INDEX `fk_CoachsTownsLangs_Coachs1` (`Coachs_Users_id` ASC) ,
INDEX `fk_CoachsTownsLangs_Towns1` (`Towns_idTowns` ASC) ,
INDEX `fk_CoachsTownsLangs_Langs1` (`Langs_idLang` ASC) ,
CONSTRAINT `fk_CoachsTownsLangs_Coachs1`
FOREIGN KEY (`Coachs_Users_id` )
REFERENCES `intelektualnie`.`Coachs` (`Users_id` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_CoachsTownsLangs_Towns1`
FOREIGN KEY (`Towns_idTowns` )
REFERENCES `intelektualnie`.`Towns` (`idTowns` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_CoachsTownsLangs_Langs1`
FOREIGN KEY (`Langs_idLang` )
REFERENCES `intelektualnie`.`Langs` (`idLang` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
答案 0 :(得分:1)
尝试更改:
->set('ctl.title', $data['title'])
到
->set('ctl.title', "'" . $data['title'] . "'")
和
->set('ctl.description', $data['description'])
到
->set('ctl.description', "'" . $data['description'] . "'")