Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

Requested JSON parse failed on Table with Foreign Key "not n

Post Reply
Biertrinker
Posts: 6
Joined: Wed Jun 29, 2016 8:53 am

Requested JSON parse failed on Table with Foreign Key "not n

Unread post by Biertrinker »

hello

i cant insert Data in a Table if the Foreign Key is set to "not null"

the Database structure:

CREATE TABLE `orte` (
`id_orte` int(11) NOT NULL AUTO_INCREMENT,
`ortsname` varchar(50) NOT NULL,
`plz` int(5) DEFAULT '0',
`info` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id_orte`)

CREATE TABLE `personen` (
`id_personen` int(11) NOT NULL AUTO_INCREMENT,
`vorname` varchar(50) DEFAULT NULL,
`nachname` varchar(50) NOT NULL,
`info` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id_personen`)


CREATE TABLE `buchungen` (
`id_buchungen` int(11) NOT NULL AUTO_INCREMENT,
`fk_orte` int(11) NOT NULL,
`fk_personen` int(11) NOT NULL,

`info` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id_buchungen`),
KEY `fk_buchungen_1` (`fk_orte`),
KEY `fk_buchungen_2` (`fk_personen`),
CONSTRAINT `fk_buchungen_1` FOREIGN KEY (`fk_orte`) REFERENCES `orte` (`id_orte`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_buchungen_2` FOREIGN KEY (`fk_personen`) REFERENCES `personen` (`id_personen`) ON DELETE CASCADE ON UPDATE CASCADE
)



Is it set to "DEFAULT NULL" then i can insert Data


CREATE TABLE `buchungen` (
`id_buchungen` int(11) NOT NULL AUTO_INCREMENT,
`fk_orte` int(11) ,
`fk_personen` int(11) ,

`info` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id_buchungen`),
KEY `fk_buchungen_1` (`fk_orte`),
KEY `fk_buchungen_2` (`fk_personen`),
CONSTRAINT `fk_buchungen_1` FOREIGN KEY (`fk_orte`) REFERENCES `orte` (`id_orte`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `fk_buchungen_2` FOREIGN KEY (`fk_personen`) REFERENCES `personen` (`id_personen`) ON DELETE CASCADE ON UPDATE CASCADE
)


i see in the NuBuilder the field "Stop Blanks" but i need the check in the MySQL Database

is there a way ?

thanks
Biertrinker
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: Requested JSON parse failed on Table with Foreign Key "n

Unread post by admin »

Biertrinker,

nuBuilder can do all the checking you like using PHP before saving anything..
beforesave.PNG
beforesave.PNG (24.22 KiB) Viewed 3018 times
eg.

Code: Select all


	if('#sre_zzzsys_sql#' == '' and '#sre_zzzsys_php_id#' == ''){

  $MESS = "SQL or PHP is required to create a Report.."; 
  nuDisplayError($MESS);

}



Steven
Post Reply