For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > April 2005 > OCI Binding problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author OCI Binding problem
Jos Juffermans

2005-04-20, 8:55 am

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com