ZF 1.12 and NULL constraint

14 views Asked by At

I use ZF 1.12 and gateway models. My problem is getting data with models, because some foreign keys may NULL, so when I ask for findDependentRowset() I got exception: Invalid parameter number: no parameters were bound, query was: SELECT `CodebookCar`.* FROM `CodebookCar` WHERE (`id` = ?)

I don't know how get data from database. Is really possible use gateway pattern or I must use LEFT JOIN?

CREATE TABLE IF NOT EXISTS `fsc_heaper`.`Order` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  `CodebookUpdateID` INT UNSIGNED NOT NULL,
  `CodebookMapID` INT UNSIGNED NOT NULL,
  `CodebookPaymentID` INT UNSIGNED NOT NULL,
  `CodebookCarID` SMALLINT UNSIGNED NULL DEFAULT NULL,
  `CodebookEmailID` TINYINT UNSIGNED NULL DEFAULT NULL,
  `CodebookPhoneID` TINYINT UNSIGNED NULL DEFAULT NULL,
  `Vin` CHAR(7) NULL DEFAULT NULL,
  `Fsc` CHAR(20) NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  INDEX `fk_Order_CodebookUpdate_idx` (`CodebookUpdateID` ASC),
  INDEX `fk_Order_CodebookMap_idx` (`CodebookMapID` ASC),
  INDEX `fk_Order_CodebookPayment_idx` (`CodebookPaymentID` ASC),
  INDEX `fk_Order_CodebookCar_idx` (`CodebookCarID` ASC),
  INDEX `fk_Order_CodebookEmail_idx` (`CodebookEmailID` ASC),
  INDEX `fk_Order_CodebookPhone_idx` (`CodebookPhoneID` ASC),
  INDEX `idx_Vin` (`Vin` ASC),
  CONSTRAINT `fk_Order_CodebookUpdate`
    FOREIGN KEY (`CodebookUpdateID`)
    REFERENCES `fsc_heaper`.`CodebookUpdate` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_Order_CodebookMap`
    FOREIGN KEY (`CodebookMapID`)
    REFERENCES `fsc_heaper`.`CodebookMap` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_Order_CodebookPayment`
    FOREIGN KEY (`CodebookPaymentID`)
    REFERENCES `fsc_heaper`.`CodebookPayment` (`id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `fk_Order_CodebookCar`
    FOREIGN KEY (`CodebookCarID`)
    REFERENCES `fsc_heaper`.`CodebookCar` (`id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `fk_Order_CodebookEmail`
    FOREIGN KEY (`CodebookEmailID`)
    REFERENCES `fsc_heaper`.`CodebookEmail` (`id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `fk_Order_CodebookPhone`
    FOREIGN KEY (`CodebookPhoneID`)
    REFERENCES `fsc_heaper`.`CodebookPhone` (`id`)
    ON DELETE SET NULL
    ON UPDATE CASCADE)
ENGINE = InnoDB;

CREATE TABLE IF NOT EXISTS `fsc_heaper`.`CodebookCar` (
  `id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Name` VARCHAR(12) NOT NULL,
  `Sort` SMALLINT UNSIGNED NULL DEFAULT NULL,
  `IsActive` TINYINT(1) NOT NULL DEFAULT 1,
  `IsDefault` TINYINT(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `ung_Identity_Name` (`Name` ASC))
ENGINE = InnoDB;
0

There are 0 answers