spence911 Posted May 16, 2014 Share Posted May 16, 2014 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 Quote Link to comment https://forums.phpfreaks.com/topic/288535-what-is-pdoparam_int/ Share on other sites More sharing options...
Ch0cu3r Posted May 16, 2014 Share Posted May 16, 2014 It is describing the data type of the bound value. Quote Link to comment https://forums.phpfreaks.com/topic/288535-what-is-pdoparam_int/#findComment-1479681 Share on other sites More sharing options...
Solution spence911 Posted May 16, 2014 Author Solution Share Posted May 16, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/288535-what-is-pdoparam_int/#findComment-1479683 Share on other sites More sharing options...
ginerjm Posted May 16, 2014 Share Posted May 16, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/288535-what-is-pdoparam_int/#findComment-1479714 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.