php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #685 odbc_exec doing duplicate, out-of-order calls
Submitted: 1998-08-22 23:35 UTC Modified: 1999-10-03 06:41 UTC
From: z-kimmel at uiuc dot edu Assigned:
Status: Closed Package: ODBC related
PHP Version: 3.0.3 OS: NT 4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: z-kimmel at uiuc dot edu
New email:
PHP Version: OS:

 

 [1998-08-22 23:35 UTC] z-kimmel at uiuc dot edu
I am writing code to insert a person's ID number and age into a database. The following code gives wacky results!
-------------------------------------------

$connection = odbc_connect("mydb","myname","mypassword");

#insert a new age into the database

$query="select * from mytable where personID=" . strval($personID) . " and personAge=" . strval($age) . ";";
$result = odbc_exec($connection,  $query);
odbc_result_all($result,"");

#****

$query="insert into mytable(personID, personAge) values (" .
	strval($personID) . "," . strval($age) . ");";
$result = odbc_exec($connection,  $query);
------------------------------------
Establishing the connection works fine. (The same problem occurs with odbc_pconnect.)

If I remove everything after the #****, then I get the expected result:
--------
No rows found
--------
But if I include the lines after the #****, I get the following result (for personID=3 and personAge=50, where these values are not already in the database):
--------
PersonID  PersonAge
 3         50
                    
Warning: SQL error: [Sybase][ODBC Driver]Integrity constraint violation: primary key for table 'mytable' is not unique, SQL state 23000 in
SQLExecDirect in makenewaccount on line 45
----------
Somehow, the "insert" statement is being executed BEFORE the "select" statement is executed, and then the "insert" statement is executed AGAIN. Maybe this is due to some multithreading effect?

The data does enter the database successfully. The code behavior described above does not seem to be due to the database itself, because if I enter the exact same commands in a different SQL interpreter on the same database all is well.

I am using Win32 PHP 3.0.3 and Apache.

--Zeba Kimmel, z-kimmel@uiuc.edu

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-10-03 06:41 UTC] kara at cvs dot php dot net
Seems to be fixed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC