Bug #685: odbc_exec doing duplicate, out-of-order calls
| From: | z-kimmel at uiuc dot edu | Date: | Sun, 23 Aug 1998 03:35:28 +0000 |
| Subject: | Bug #685: odbc_exec doing duplicate, out-of-order calls | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-517@lists.php.net to get a copy of this message | ||
From: z-kimmel@uiuc.edu
Operating system: NT 4
PHP version: 3.0.3
PHP Bug Type: ODBC related
Bug description:
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
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net