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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:13:11+00:00 2026-06-17T20:13:11+00:00

While introducing myself to pgSQL prepared statements, I’ve successfully returned the results of a

  • 0

While introducing myself to pgSQL prepared statements, I’ve successfully returned the results of a few queries. However, I have a few questions.

Given the following query:

$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();

I notice that even though the column in the main_products_common_dimensions table is a character_varying, I get the same/correct result set returned if I use

$w_ft = 36; 
...
$sth->bindParam(':w_ft', $w_ft, PDO::PARAM_INT);

and

$w_ft = "36"; 
...
$sth->bindParam(':w_ft', $w_ft, PDO::PARAM_STR);

and

$w_ft = "36"; 
...
$sth->bindParam(':w_ft', $w_ft, PDO::PARAM_INT);

and

$w_ft = 36; 
...
$sth->bindParam(':w_ft', $w_ft, PDO::PARAM_STR);

That is, no matter how I bind the parameter _INT or _STR or set the variable (integer or string), the data is returned correctly. Is this normal behavior?

From http://php.net/manual/en/pdostatement.bindparam.php, I see that the parameter datatype is explained

Explicit data type for the parameter using the PDO::PARAM_* constants.
To return an INOUT parameter from a stored procedure, use the bitwise
OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type
parameter.

What is meant by “returning an INOUT parameter from a stored procedure”? Is this related? Does that imply that I am not using a stored procedure? Length seems to be optional, though that is not indicated in its explanation. Are there advantages to providing it?

As you can see, I’m quite new to this, and just trying to get my head around it. Thank you very much

  • 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-17T20:13:12+00:00Added an answer on June 17, 2026 at 8:13 pm

    PDO::PARAM_INT and PDO::PARAM_STR when passed to bindParam() are indications that the driver is free to ignore.

    Looking at PDO pg driver’s source code, it appears that, except for PDO_PARAM_LOB which is treated specially, all types are quoted as strings (that is, between quotes and passed to libpq’s PQescapeStringConn function)

    You should also be aware of the PDO::ATTR_EMULATE_PREPARES attribute that controls what method is used under the hood. When false, PQprepare() is used with real out-of-query parameters. If true, parameter values are injected into the SQL passed to the non-parametrized PQexec().
    Technically, this is quite different, so you may see differing behaviors in corner cases or error cases depending on this attribute.

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

Sidebar

Related Questions

I am facing an issue while executing queries.I use the same resultSet and statement
I have a stored procedure that has several transactions in a loop: WHILE @COUNT
We use Subversion and aside from a few individuals such as myself there is
I am fascinated with non-blocking architectures. While I haven't used Node.js, I have a
While looking into Can you have a incrementor and a decrementor on the same
While debugging and keep pressing F5, if the source code does not exist, eclipse
While trying to build the mysql2 gem with ruby 1.9.2-p320 on Fedora 16, I
While deveoping a site (using Forms authentication and InProc sessionstate) a frequently run into
While developing an application using gwt in ecliplse crashed. Now the server is running
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I

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.