php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11819 Bug with ibase_execute()
Submitted: 2001-07-01 04:03 UTC Modified: 2001-07-06 06:13 UTC
From: flying at dom dot natm dot ru Assigned:
Status: Not a bug Package: InterBase related
PHP Version: 4.0.6 OS: Windows 2000
Private report: No CVE-ID: None
 [2001-07-01 04:03 UTC] flying at dom dot natm dot ru
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.
 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-01 06:57 UTC] derick@php.net
This is not a PHP bug. Interbase gives you a warning, and not PHP. (PHP merely shows the warning for you).

Derick
 [2001-07-06 06:13 UTC] flying at dom dot natm dot ru
Look at PHP scripts, I was posted, one more time. You'll see, that this warning was disappeared, when PHP (!) code was changed (note, nothing else, just PHP code!).  And one more thing: all other programs doesn't cause this warning to appear in the same situation. So, as I said before, it seems, that PHP itself hadles this situation incorrectly (maybe wrong parameters are passed to InterBase or something else). And problem is still exists, even into 4.0.6
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC