INSERT query with Primary and foreign key

--0-1788937395-1203988502=:6075
Content-Type: text/plain; charset=us-ascii

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

--0-1788937395-1203988502=:6075--
Nasreen Laghari [ Di, 26 Februar 2008 02:15 ] [ ID #1925998 ]

RES: 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:nasreen_laghari [at] yahoo.com]
Enviada em: segunda-feira, 25 de fevereiro de 2008 22:15
Para: php-db [at] 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
Thiago Pojda [ Di, 26 Februar 2008 13:17 ] [ ID #1926000 ]

RE: RES: INSERT query with Primary and foreign key

--_c22f7b06-541c-49ae-9962-2a3fc5c0a42a_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


do you mean that you have a primary key on table a with an fk to table b? a=
nd 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 tabl=
e 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: thiago.pojda [at] softpartech.com.br> To: nasreen_laghari [at] yahoo.com; php=
-db [at] lists.php.net> Date: Tue, 26 Feb 2008 09:17:30 -0300> Subject: RES: [PH=
P-DB] INSERT query with Primary and foreign key> > This is more SQL than PH=
P, how did you create your constraints?> > Did you set insert on CASCADE?> =
> -----Mensagem original-----> De: Nasreen Laghari [mailto:nasreen_laghari [at] =
yahoo.com] > Enviada em: segunda-feira, 25 de fevereiro de 2008 22:15> Para=
: php-db [at] lists.php.net> Assunto: [PHP-DB] INSERT query with Primary and for=
eign key> > Hi,> > I need help to insert date into two tables when tables h=
ave 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! Mo=
bile. Try it now.> http://mobile.yahoo.com/;_ylt=3DAhu06i62sR8HDtDypao8Wcj9=
tAcJ > > -- > PHP Database Mailing List (http://www.php.net/)> To unsubscri=
be, visit: http://www.php.net/unsub.php>
____________________________________________________________ _____


--_c22f7b06-541c-49ae-9962-2a3fc5c0a42a_--
Bastien Koert [ Di, 26 Februar 2008 15:14 ] [ ID #1926005 ]

Re: INSERT query with Primary and foreign key

On Mon, Feb 25, 2008 at 8:15 PM, Nasreen Laghari
<nasreen_laghari [at] yahoo.com> 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?

--
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
parasane [ Di, 26 Februar 2008 16:36 ] [ ID #1926007 ]
PHP » gmane.comp.php.database » INSERT query with Primary and foreign key

Vorheriges Thema: MySQL replication delaying issue
Nächstes Thema: Encrypting user information and Data Retention Laws (US)