Jump to content

Recommended Posts

What's up guys! Can somebody please explain the meaning of PDO::PARAM_INT in the following statement:

$pdoStmt->bindValue(":num", $num, PDO::PARAM_INT);

I have already created a PDO Statement object called $pdoStmt. This line will bind the value of $num to the placeholder called :num. I know that PDO::PARAM_INT is a Predefined Constant but what does it do in this case? Thanx

Link to comment
https://forums.phpfreaks.com/topic/288535-what-is-pdoparam_int/
Share on other sites

  • Solution

Just figured this out. Its a constant that ensures that the data returned is an integer(TINYINT, MEDIUMINT, BIGINT...) so that PDO can pass the correct data type to MySQL. PDO will also escape any quotes and other characters thereby preventing SQL injection.

Which you could have found out rather quickly by reading about the 'bindvalue' statement in the MANUAL

 

It is simply amazing how so many would-be programming types visit forums with questions that are so easily answered with a little research  (aka, reading!) in the most appropriate place, namely, the manual. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.