Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:16:22+00:00 2026-06-01T17:16:22+00:00

If I have a correctly working postgres function (similar to below); package.func_SetValues(id integer, values

  • 0

If I have a correctly working postgres function (similar to below);

package."func_SetValues"(id integer, values integer[])
    DECLARE
        i integer;
    BEGIN
    FOR i IN 1..array_upper(values, 1) 
      LOOP
       EXECUTE package."func_DoStuff"(id, values[i]);
      END LOOP;
    END
    LANGUAGE 'plpgsql' VOLATILE

And, a PHP script, doStuff.php, calling this function which accepts and uses the values as url encoded parameters.

$dbconn = pg_connect("host=192.168.1.222 port=5432 dbname=betya user=betya_user password=bettyboo")
    or die('Could not connect: ' . pg_last_error());
$query = 'SELECT * FROM package."func_SetValues"($1, $2)';
$result=pg_prepare($dbconn, "qy", $query);
$paramater1=$_REQUEST['id'];    
$paramater2=$_REQUEST['arr']; 
$result=pg_execute($dbconn, "qy", array($paramater1, $paramater2));

while($e=pg_fetch_assoc($result))
$output[]=$e;

print(json_encode($output));
pg_free_result($result);
pg_close($dbconn);

To test the PHP script, does the following URL correctly encode the array ‘arr’ in a way that PHP can “Request” the values and can pass to postgres in away that it understands? Or is further functionality required in the script to correctly pass to the pg_execute command?

http://192.168.1.50/server/doStuff.php?id=1790&arr[]=1788&arr[]=1790&arr[]=1805
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:16:23+00:00Added an answer on June 1, 2026 at 5:16 pm

    Yes, further code is required. The array has to be non-trivially converted to be passed as a parameter, because PG expects it in textual form as described in the doc:
    http://www.postgresql.org/docs/current/static/arrays.html#ARRAYS-IO

    In another question: PHP array to postgres array , a PHP function to that effect has been already submitted to S.O., it might just be what you need (and ever better since it supports recursive arrays).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this button which is not working correctly for hold button for a
This was working correctly in Visual Studio 2008, but since I have switch to
I`m currently working on a script, and I have the following situation. function somnicefunction()
I have an application script that is working correctly, but I have a few
I am using hashmap, but it is not working correctly. I have a class
I have successfully followed Ryan Bates tutorial of paperclip and have it working correctly.
I have some code that is working correctly in Java but when I try
I have tried many things to get this working correctly but I can't Here
I have tried various methods to try and get this working correctly (I am
I have three tables and two seperate SQL queries which are working correctly and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.