|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-07-01 06:57 UTC] derick@php.net
[2001-07-06 06:13 UTC] flying at dom dot natm dot ru
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 12:00:01 2025 UTC |
Environment: - Windows 2000 Server - Apache v1.3.20 (binaries from www.apache.org) - PHP v4.0.5 (binaries from www.php.net) - InterBase v6.0.0.627 (binaries from www.borland.com) 1. Create very simple database: ----------------------------------------------------------------- CREATE DATABASE 'c:\db\test.gdb' USER 'user' PASSWORD 'password'; CREATE TABLE TABLE_1 ( ID_1 INTEGER NOT NULL); CREATE TABLE TABLE_2 ( ID_2 INTEGER NOT NULL, FK INTEGER); ALTER TABLE TABLE_1 ADD CONSTRAINT PK_1 PRIMARY KEY (ID_1); ALTER TABLE TABLE_2 ADD CONSTRAINT PK_2 PRIMARY KEY (ID_2); ALTER TABLE TABLE_2 ADD CONSTRAINT FK_2_1 FOREIGN KEY (FK) REFERENCES TABLE_1 (ID_1); COMMIT WORK; ----------------------------------------------------------------- 2. Create very simple PHP script: ----------------------------------------------------------------- <?php $ib = ibase_connect('c:\db\test.gdb','user','password'); $query = ibase_prepare($ib,'insert into TABLE_2(ID_2, FK) values (?, ?)'); $rs = ibase_execute($query,1,null); ibase_close($ib); ?> ----------------------------------------------------------------- 3. Run it and look at the following error: ----------------------------------------------------------------- Warning: InterBase: violation of FOREIGN KEY constraint "FK_2_1" on table "TABLE_2" in test.php on line 5 ----------------------------------------------------------------- Note, that if we'll insert non-NULL value into TABLE_2.FK, then all will work fine. 4. Rewire our PHP script slightly: ----------------------------------------------------------------- <?php $ib = ibase_connect('c:\db\test.gdb','user','password'); $query = ibase_query($ib,"insert into TABLE_2(ID_2, FK) values (1,null)"); ibase_close($ib); ?> ----------------------------------------------------------------- 5. Run it and note, that all works fine! So, there is a serious bug into ibase_execute() function, which prevents first version of PHP script from working properly.