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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:17:13+00:00 2026-05-11T17:17:13+00:00

I’m wondering what the declaration of the data type in bindParam() (or bindValue() )

  • 0

I’m wondering what the declaration of the data type in bindParam() (or bindValue()) is used for…

I mean, I thought that if I define an integer argument (PDO::PARAM_INT), the argument must be converted to an integer, something like

$delete->bindParam(1, $kill, PDO::PARAM_INT);
// should work like
$delete->bindParam(1, (int)$kill);

or at least throw an error if the argument is not of the declared type. But this is not the case.

Googling around, I found that in the php.net archive:

Hi all,

I am currently working on PDO. Exactly
on the bindParam() function. The third
parameter data_type seems to be here
to force the type of the value ? But
when I try :

$sql = "INSERT INTO produit (idproduit, nom, marque) VALUES (NULL, :nom, :marque)";
$stmt = $dbh->prepare($sql);
$nom = 'Testarossa'; $marque = 'Ferrari' ;
$stmt->BindValue(':marque',$marque) ;
$stmt->BindParam(':nom',$nom,PDO::PARAM_INT) ;

$stmt->execute(); $nom = '250 GTO' ;
$stmt->execute(); ?>

I was expecting to have either a PHP
error or an interger in my database.
But in my DB I have :

22 Testarossa Ferrari 23 250 GTO
Ferrari

It mean that it didn’t change if I
have the third parameter or not. Or
perhaps I miss something. Can someone
tole me more ? Or just can someone
told me where I can find information
about it.

Regards,

Cyruss

That is exactly my situation. Where are my thoughts going wrong?

  • 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-11T17:17:14+00:00Added an answer on May 11, 2026 at 5:17 pm

    It can be used for things like making sure PDO is doing the proper escaping for in-lining values (for drivers that don’t support proper bound parameters) and improving network efficiency by making sure numbers are binary packed appropriately (given protocol support).

    It looks like in base PDO, it doesn’t do much.

    if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && !Z_ISNULL_P(parameter)) {
        if (!try_convert_to_string(parameter)) {
            return 0;
        }
    } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE)) {
        convert_to_long(parameter);
    } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && Z_TYPE_P(parameter) == IS_LONG) {
        convert_to_boolean(parameter);
    }
    

    So, if you say it is a string (or if you say nothing at all as that is the default) and your data’s type is something other than a NULL then it will convert it into a string.

    If you say it’s an int but you bind a bool then it will convert it to an integer.

    If you say it’s a bool but you bind a number then it will convert it to a true boolean.

    When emulation mode is turned on, the type hint is used to determine how to inject it into the SQL string.

    Additionally, PDO provides this information to the database drivers, which can then be used to bind the data most optimally or correctly, depending on the particular DB’s requirements.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Some ideas that could help : check potential differences of… May 11, 2026 at 11:48 pm
  • Editorial Team
    Editorial Team added an answer Basically no. You could attempt to do it by writing… May 11, 2026 at 11:48 pm
  • Editorial Team
    Editorial Team added an answer Try: .Where(rules.Select(r => r.ID).Contains(arr.AuditRuleEnterpriseID.AuditID)) or, in query syntax where rules.Select(r… May 11, 2026 at 11:48 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.