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 9170455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:01:18+00:00 2026-06-17T16:01:18+00:00

I notice that these two ways of structuring a query with PHP PDO, both

  • 0

I notice that these two ways of structuring a query with PHP PDO, both return the same data.

//prepare with $dbh->prepare
$w_ft = "36"; 
$sth = $dbh->prepare("SELECT * FROM main_products_common_dimensions WHERE w_ft = :w_ft");
$sth->bindParam(':w_ft', $theId, PDO::PARAM_INT);
$sth->execute();
$result = $sth->fetchAll(); //PHP array of data


//prepare with pg_prepare()
$result = pg_prepare($con, "my_query", 'SELECT * FROM main_products_common_dimensions WHERE w_ft = $1');
$result = pg_execute($con, "my_query", array("48")); //A query result resource on success or FALSE on failure.
while ($row = pg_fetch_assoc($result)){
    echo $row['w_ft'] . "<BR>"; 
}

I read at http://php.net/manual/en/function.pg-execute.php that the second way returns “A query result resource on success or FALSE on failure.” So I tried to iterate through it with pg_fetch_assoc(). It works, but is that not deprecated along with the rest of the pg_sql functions? Should I be using something in the PDO to look at the results of the query?

For this reason, I’m inclined to use the first method while using PDO. Is this the norm?

My question is how to submit multiple values to either method. Neither method works when I try to submit an array to the prepared statement

$w_ft = array("48", "36"); 


$result = pg_execute($con, "my_query", array("48", "36"));

I thought that I was able to submit multiple values to the query in this way. How can I do this?

Thank you

  • 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-17T16:01:18+00:00Added an answer on June 17, 2026 at 4:01 pm

    Looks like you’re taking execute array wrong.
    It takes values not for the consequent executions but for one execution only.
    So, number of values should be equal to number of placeholders.
    So it goes

    $sql = 'SELECT * FROM table WHERE w_ft = $1 OR w_ft = $2 OR w_ft = $3'
    

    for your array("48", "36", "12")

    I am not a PG user though, so, I can confuse some syntax.

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

Sidebar

Related Questions

I noticed recently that there are two ways to print multiple statements in PHP.
I've notice that when one of the two conditions in a php if statement
So I've noticed that there seem to be two ways to get the same
I was looking at some lint errors and notice that there are two ways
I was checking out the Tweet# API, and notice that there are 2 ways
Both of these frameworks are great, but I've noticed that Knockout likes to point
I've noticed that there are two different ways to load nib/xib files: via the
I have noticed that there are two ways to cast objects (the difference is
In Chrome the console object defines two methods that seem to do the same
I'm consolidating code written by two different people and notice that casting a String

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.