Subject Re: [firebird-php] Variable parameters number
Author Lester Caine
masotti wrote:
> Converting a project from Delphi to PHP, I've a set of query (generic
> SIUD) stored somewhere.
> At a certain moment I've a centralized function with:
> - query source
> - parameters names and values
>
> I don't know number and order of parameters.
> For number of parameters, ibase_prepare()+ibase_num_params() can solve,
> but ibase_param_info() works only for type and length: name is "".
> I'm not able to find a solution to know order of parameters. If it'd
> possible, I can use eval() as last resource.
> Are ther any other solution than writing query with named parameters
> (i.e. like BDE's :PARAM_NAME) and substituting all references in query
> source string the hard way?

I'm not sure I understand the problem Mimmo. Even in Delphi you have to keep
the parameter order the same when running the query, but if you have that all
hidden by another layer of code I think I understand. In the ADOdb php library
I build the query and the array of parameters in parallel, so there is not a
problem. Your current 'library' must have some means of identifying which
parameter goes with which '?' even if it is hidden, but suspect that
information is not stored with the query? So the best generic method would be
to expand the query to add identifiers for the parameters - as in :xxx and
then parse the query to select the correct parameter order. Alternatively
since the parameter order HAS to be fixed for a particular query, then each
query could have a second stored item with the parameter list. THAT is how I
suspect your Delphi application is working internally?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php