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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
7 - 4 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 15:01:29 2024 UTC