Subject RE: [firebird-php] Input arrays for use in stored procedures?
Author Alan McDonald
mind you - you could also build a query script side which would be in the
form
UPDATE TABLE SET FLAG=VALUE WHERE ID IN( list )
where you build the comma separated list then place it in the query line
before execution.
If the list is long - I would do it either though. typical page may be 50
items - that would be my limit using this syntax.
the method below would be better on longer lists.
Alan
-----Original Message-----
From: firebird-php@yahoogroups.com [mailto:firebird-php@yahoogroups.com]On
Behalf Of Alan McDonald
Sent: Wednesday, 8 June 2005 5:58 PM
To: firebird-php@yahoogroups.com
Subject: RE: [firebird-php] Input arrays for use in stored procedures?


I still do the boring multiple calls to an SP via this method:


if (($_POST['saverecflags']=="ok")) {
foreach ($_POST as $fieldName=>$fieldValue) {
if (gettype($fieldValue) == 'array') {
$iCount = count($_POST[$fieldName]);
for ($i=0;$i<$iCount;$i++) {
$fieldValue = $_POST[$fieldName][$i];
if ($fieldName=='hrecon'){
$db->get_var("UPDATE C_LOAN SET RECONCILEFLAG='N' WHERE
C_LOAN.ID=".$fieldValue);
}
if ($fieldName=='cbrecon') {
$db->get_var("UPDATE C_LOAN SET RECONCILEFLAG='Y' WHERE
C_LOAN.ID=".$fieldValue);
}
}
}
}
}


the fields on the page can be the same name as long as they are marked as
an
array

<input type='checkbox' name='cbrecon[]' value=".$loanid."
".($C48=='Y'?'checked':'')." >

the looping in the script still goes on server side so I don;t see any
performance difference between scripting a page full of updates Vs
executing
one SP with an array - the SP still has to execute multiple updates.
Anyway - passing array inputs... I don't go there :-)


Alan
-----Original Message-----
From: firebird-php@yahoogroups.com
[mailto:firebird-php@yahoogroups.com]On
Behalf Of willogibbo
Sent: Wednesday, 8 June 2005 5:46 PM
To: firebird-php@yahoogroups.com
Subject: [firebird-php] Input arrays for use in stored procedures?


Hi all

I am developing a web based application using PHP with Firebird 1.5.
Certain pages take input from the user to update tables in the
database - all quite normal.

In some instances I have a form on which the user can change values
down a column in a recordset. I would like to be able to take these
multiple input values, as an array, and use them as input for a stored
procedure that does the updates as one "batch" (rather than construct
a loop in PHP, i.e.outside Firebird, that ends up doing multiple
individual ordinary update queries).

Question is, therefore, how is it possible to use multiple values i.e.
an array, as input parameter for a stored procedure, and for the SP to
loop through and process these values?

Thanks, Will

(this question posted to both this and Firebird-Support forum as I'm
not sure which is best?)





--------------------------------------------------------------------------
--
--
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-php/

b.. To unsubscribe from this group, send an email to:
firebird-php-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.



[Non-text portions of this message have been removed]



----------------------------------------------------------------------------
--
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-php/

b.. To unsubscribe from this group, send an email to:
firebird-php-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]