[PHP-DB] OCI Binding problem
Hi, Imagine this code: ?php $database_connection = ocilogon(username, password, connection string); // the actual connection code is slightly different but that is not relevant to my problem $postalcode = 3055; // option 1: paste the postalcode into the query: $rowset1 = array(); $statement1 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=' . $postalcode . '); ociexecute($statement1); ocifetchstatement($statement1, $rowset1, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset1 contains some records from the table // option 2: use namebinding: $rowset2 = array(); $statement2 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=:postalcode); ocibindbyname($statement2, :postalcode, $postalcode, 4); ociexecute($statement2); ocifetchstatement($statement2, $rowset2, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset2 is still an empty array ? Both queries should result in the same data but as soon as I use the binding no rows are returned. I can't see what I'm doing wrong here. Can someone help me? Jos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] OCI Binding problem
Sorry, trigger happy. Also try :postalcode in uppercase. Neil -Original Message- From: Juffermans, Jos [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 12:18 To: 'php-db@lists.php.net' Subject: [PHP-DB] OCI Binding problem Hi, Imagine this code: ?php $database_connection = ocilogon(username, password, connection string); // the actual connection code is slightly different but that is not relevant to my problem $postalcode = 3055; // option 1: paste the postalcode into the query: $rowset1 = array(); $statement1 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=' . $postalcode . '); ociexecute($statement1); ocifetchstatement($statement1, $rowset1, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset1 contains some records from the table // option 2: use namebinding: $rowset2 = array(); $statement2 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=:postalcode); ocibindbyname($statement2, :postalcode, $postalcode, 4); ociexecute($statement2); ocifetchstatement($statement2, $rowset2, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset2 is still an empty array ? Both queries should result in the same data but as soon as I use the binding no rows are returned. I can't see what I'm doing wrong here. Can someone help me? Jos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] OCI Binding problem
Jos, This may or may not sort out the problem, but OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW should be OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW. Neil -Original Message- From: Juffermans, Jos [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 12:18 To: 'php-db@lists.php.net' Subject: [PHP-DB] OCI Binding problem Hi, Imagine this code: ?php $database_connection = ocilogon(username, password, connection string); // the actual connection code is slightly different but that is not relevant to my problem $postalcode = 3055; // option 1: paste the postalcode into the query: $rowset1 = array(); $statement1 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=' . $postalcode . '); ociexecute($statement1); ocifetchstatement($statement1, $rowset1, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset1 contains some records from the table // option 2: use namebinding: $rowset2 = array(); $statement2 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=:postalcode); ocibindbyname($statement2, :postalcode, $postalcode, 4); ociexecute($statement2); ocifetchstatement($statement2, $rowset2, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset2 is still an empty array ? Both queries should result in the same data but as soon as I use the binding no rows are returned. I can't see what I'm doing wrong here. Can someone help me? Jos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] OCI Binding problem
Hi, Since flags are normally bitmaps, FLAG1 | FLAG2 should have the same result as FLAG1 + FLAG2. I've tried your suggestion anyway but it had no result. I've also tried to uppercase :postalcode (in the query and in the bindbyname call) but that didn't help either. Jos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 13:40 To: [EMAIL PROTECTED]; php-db@lists.php.net Subject: RE: [PHP-DB] OCI Binding problem Sorry, trigger happy. Also try :postalcode in uppercase. Neil -Original Message- From: Juffermans, Jos [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 12:18 To: 'php-db@lists.php.net' Subject: [PHP-DB] OCI Binding problem Hi, Imagine this code: ?php $database_connection = ocilogon(username, password, connection string); // the actual connection code is slightly different but that is not relevant to my problem $postalcode = 3055; // option 1: paste the postalcode into the query: $rowset1 = array(); $statement1 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=' . $postalcode . '); ociexecute($statement1); ocifetchstatement($statement1, $rowset1, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset1 contains some records from the table // option 2: use namebinding: $rowset2 = array(); $statement2 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=:postalcode); ocibindbyname($statement2, :postalcode, $postalcode, 4); ociexecute($statement2); ocifetchstatement($statement2, $rowset2, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset2 is still an empty array ? Both queries should result in the same data but as soon as I use the binding no rows are returned. I can't see what I'm doing wrong here. Can someone help me? Jos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Recall: [PHP-DB] OCI Binding problem
Juffermans, Jos would like to recall the message, [PHP-DB] OCI Binding problem. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] OCI Binding problem
Update: I've found a workaround: ?php $database_connection = ocilogon(username, password, connection string); // the actual connection code is slightly different but that is not relevant to my problem $postalcode = 3055; $rowset2 = array(); $statement2 = ociparse($database_connection, SELECT services FROM location WHERE postalcode='' || :postalcode); ocibindbyname($statement2, :postalcode, $postalcode, 4); ociexecute($statement2); ocifetchstatement($statement2, $rowset2, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // this returns the records ? Somehow Oracle will interpret the :postalcode as a numeric value in this case, eventhough the column is a varchar. By adding '' || Oracle converts it to a string. Jos -Original Message- From: Juffermans, Jos [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 14:05 To: 'php-db@lists.php.net' Subject: RE: [PHP-DB] OCI Binding problem Hi, Since flags are normally bitmaps, FLAG1 | FLAG2 should have the same result as FLAG1 + FLAG2. I've tried your suggestion anyway but it had no result. I've also tried to uppercase :postalcode (in the query and in the bindbyname call) but that didn't help either. Jos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 13:40 To: [EMAIL PROTECTED]; php-db@lists.php.net Subject: RE: [PHP-DB] OCI Binding problem Sorry, trigger happy. Also try :postalcode in uppercase. Neil -Original Message- From: Juffermans, Jos [mailto:[EMAIL PROTECTED] Sent: 20 April 2005 12:18 To: 'php-db@lists.php.net' Subject: [PHP-DB] OCI Binding problem Hi, Imagine this code: ?php $database_connection = ocilogon(username, password, connection string); // the actual connection code is slightly different but that is not relevant to my problem $postalcode = 3055; // option 1: paste the postalcode into the query: $rowset1 = array(); $statement1 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=' . $postalcode . '); ociexecute($statement1); ocifetchstatement($statement1, $rowset1, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset1 contains some records from the table // option 2: use namebinding: $rowset2 = array(); $statement2 = ociparse($database_connection, SELECT services FROM location WHERE postalcode=:postalcode); ocibindbyname($statement2, :postalcode, $postalcode, 4); ociexecute($statement2); ocifetchstatement($statement2, $rowset2, 0, 100, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); // at this stage $rowset2 is still an empty array ? Both queries should result in the same data but as soon as I use the binding no rows are returned. I can't see what I'm doing wrong here. Can someone help me? Jos -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php