Subject Re: Input arrays for use in stored procedures?
Author willogibbo
Alan
Thanks for prompt response.

Yes, I think I saw you gave a similar reply to another post a while
back. I guess I just figured there must be a way to do this in an SP
in one step - but as you say, maybe there is no difference and nothing
to worry about performance-wise.

Will



--- In firebird-php@yahoogroups.com, "Alan McDonald" <alan@m...> wrote:
> 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]