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

  • Home
  • SEARCH
  • 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 331649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:47:38+00:00 2026-05-12T09:47:38+00:00

How do you read the following code about pg_query_params and pg_prepare ? $result =

  • 0

How do you read the following code about pg_query_params and pg_prepare?

$result = pg_query_params ( $dbconn,        
    "SELECT flagged_for_moderator_removal           // unsure about Repetition here
    FROM questions 
    WHERE question_id = $1",
    array ( $_GET['question_id'] ) );

if ( pg_num_rows ( $result ) == 0 ) { 
    $result = pg_prepare ( $dbconn, "get_flagged_status_list",    
        "SELECT flagged_for_moderator_removal       // unsure about Repetition here
        FROM questions 
        WHERE question_id = $1"
    );  
} 

This question is related to my thread where I do not want to declare twice the prepared statement.

The difference between statements is that the other has a name get_flagged_status_list, while the other one does not. I understand the code as follows

Iteration |  1                     2
----------------------------------------------------------------------
           run pg_query_params    run pg_qeury_params
           run pg_prepare         
           run pg_execute         run pg_execute

However, this is not true, since the code runs pg_prepare in the second iteration too.
1.

  • 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-05-12T09:47:38+00:00Added an answer on May 12, 2026 at 9:47 am

    Your posted example does not make sense – pg_prepare() and pg_query_params() are independent functions with different purposes that you would not normally use in conjunction.

    pg_prepare() prepares a statement (a query) for later execution via pg_execute(). This is done as an potential optimization – if you know in advance that you will need to execute the statement many times in a row, preparing it upfront can save some work on the database server, since it does not have to (re-)prepare the statement for each call.

    pg_query_params() (as well as its ‘simpler’ version pg_query()) just executes the statement (query) directly, forcing the database server to (re)prepare the statement each time the function gets called.

    So in short, this

    $result = pg_query_params($query, $params);
    

    will give you the exact same result as this

    $statement = pg_prepare($query);
    $result = pg_execute($statement, $params);
    

    The only difference is that in the second case, you still have the prepared statement, ready to reuse for more calls to pg_execute() – which is why you can give it a name, since that way you can have different prepared statements on the same connection that you can execute as you please, many times, in arbitrary order.

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

Sidebar

Ask A Question

Stats

  • Questions 201k
  • Answers 201k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Code Repository: Add Mercurial - Its the only free, distributed… May 12, 2026 at 8:09 pm
  • Editorial Team
    Editorial Team added an answer You can use the CLR debugger, which is part of… May 12, 2026 at 8:09 pm
  • Editorial Team
    Editorial Team added an answer I found a solution. I have to override the ItemsPanel… May 12, 2026 at 8:09 pm

Related Questions

I am working with the Silverlight RIA Services and I want to create custom
I want the eclipse Java Compiler Warnings available as an ant task (ie without
I am asking for help on self-help, which is kind of an oxymoron. How
I have a 2 MB file, not too large, that I'd like to put

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.