Re: [PHP-DB] INSERT query with Primary and foreign key
On Mon, Feb 25, 2008 at 8:15 PM, Nasreen Laghari <[EMAIL PROTECTED]> wrote: > Hi, > > I need help to insert date into two tables when tables have primary and > foreign key relationship using php. I tried simple INSERT query but foreign > key colum is storing NULL. What's your SQL query string, Nasreen? -- Daniel P. Brown Senior Unix Geek -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: RES: [PHP-DB] INSERT query with Primary and foreign key
do you mean that you have a primary key on table a with an fk to table b? and on table b you have a primary key and an fk to table a? if so, you've created a circular referential integrity constraint. The table deadlocks since the values must exist in the other (tables a and b) table. There are several solutions: 1. if the db supports it, use deferred constraints (check the docs) 2. remove one of the FK constraints from one of the tables Bastien > From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]; php-db@lists.php.net> Date: > Tue, 26 Feb 2008 09:17:30 -0300> Subject: RES: [PHP-DB] INSERT query with > Primary and foreign key> > This is more SQL than PHP, how did you create your > constraints?> > Did you set insert on CASCADE?> > -Mensagem > original-> De: Nasreen Laghari [mailto:[EMAIL PROTECTED] > Enviada em: > segunda-feira, 25 de fevereiro de 2008 22:15> Para: php-db@lists.php.net> > Assunto: [PHP-DB] INSERT query with Primary and foreign key> > Hi,> > I need > help to insert date into two tables when tables have primary and> foreign key > relationship using php. I tried simple INSERT query but foreign> key colum is > storing NULL.> > Regards> > Nasreen> > > > > > > > Be a better friend, newshound, and> know-it-all with Yahoo! Mobile. > Try it now.> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > > -- > PHP Database Mailing List (http://www.php.net/)> To unsubscribe, visit: > http://www.php.net/unsub.php> _
RES: [PHP-DB] INSERT query with Primary and foreign key
This is more SQL than PHP, how did you create your constraints? Did you set insert on CASCADE? -Mensagem original- De: Nasreen Laghari [mailto:[EMAIL PROTECTED] Enviada em: segunda-feira, 25 de fevereiro de 2008 22:15 Para: php-db@lists.php.net Assunto: [PHP-DB] INSERT query with Primary and foreign key Hi, I need help to insert date into two tables when tables have primary and foreign key relationship using php. I tried simple INSERT query but foreign key colum is storing NULL. Regards Nasreen Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] INSERT query with Primary and foreign key
Hi, I need help to insert date into two tables when tables have primary and foreign key relationship using php. I tried simple INSERT query but foreign key colum is storing NULL. Regards Nasreen Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ