Subject | Serious PHP question |
---|---|
Author | Nigel Weeks |
Post date | 2003-06-23T04:04:37Z |
I'm using PHP, and FirebirdSQL, and I've hit a big snag...
I'm trying to use a stored procedure that requires quotes around the input
parameters(it's a varchar, with spaces all through it)
There are no examples of how to get it to go.
Here's a test case:
create table tbl_test (
str_test VARCHAR(100)
);
set term !! ;
create procedure sp_find (
str_test varchar(100)
) returns (
int_count INTEGER
) AS BEGIN
select count(*) from tbl_test where str_test = :str_test INTO :int_count;
suspend;
END !!
set term ; !!
The procedure is simplified for example purposes.
Now the PHP side:
$prep = ibase_prepare("SELECT * FROM SP_FIND(?)");
while($name = (gets set from another query - but can contain spaces)){
$extravar = $name->STR_TEST; // Put it into another variable
$rec = ibase_execute($prep,$extravar);
--------if $extravar has spaces, it dies--------
$rec = ibase_execute($prep,'$extravar');
--------it dies all the time, "Value '?' unknown" -----------
How are parameters for Stored. Procs quoted when necessary?
You are the last resort...
--------------------------------------------------------
Nigel Weeks
E-Easy
15 Wellington St. Launceston Tas 7250
Ph. 61 3 6334 6664
Fax. 61 3 6331 7032
Email. nigel@...
Web: www.e-easy.com.au
--------------------------------------------------------
I'm trying to use a stored procedure that requires quotes around the input
parameters(it's a varchar, with spaces all through it)
There are no examples of how to get it to go.
Here's a test case:
create table tbl_test (
str_test VARCHAR(100)
);
set term !! ;
create procedure sp_find (
str_test varchar(100)
) returns (
int_count INTEGER
) AS BEGIN
select count(*) from tbl_test where str_test = :str_test INTO :int_count;
suspend;
END !!
set term ; !!
The procedure is simplified for example purposes.
Now the PHP side:
$prep = ibase_prepare("SELECT * FROM SP_FIND(?)");
while($name = (gets set from another query - but can contain spaces)){
$extravar = $name->STR_TEST; // Put it into another variable
$rec = ibase_execute($prep,$extravar);
--------if $extravar has spaces, it dies--------
$rec = ibase_execute($prep,'$extravar');
--------it dies all the time, "Value '?' unknown" -----------
How are parameters for Stored. Procs quoted when necessary?
You are the last resort...
--------------------------------------------------------
Nigel Weeks
E-Easy
15 Wellington St. Launceston Tas 7250
Ph. 61 3 6334 6664
Fax. 61 3 6331 7032
Email. nigel@...
Web: www.e-easy.com.au
--------------------------------------------------------