PDO - bindParam and variables type

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rik
Forum Newbie
Posts: 4
Joined: Fri Jan 30, 2009 11:56 am
Location: Italy

PDO - bindParam and variables type

Post by Rik »

Hi all!
Little question (for those who already know the answer :) )

Code: Select all

$stm->bindParam(1,$id,PDO::PARAM_INT);
$db->execPrepare();
PDO::PARAM_INT really force $id to be seen/written as integer the same as

Code: Select all

$db->execPrepare(array( settype($id,'int') ));
or is only usefull with store procedures?
Rik
Forum Newbie
Posts: 4
Joined: Fri Jan 30, 2009 11:56 am
Location: Italy

Re: PDO - bindParam and variables type

Post by Rik »

Autoreply: No, at least not with my test on DB. In fact

Code: Select all

$stm->bindParam(5,$fields['description'],PDO::PARAM_INT);
save regularly the alfanumeric field ignoring PARAM_INT, while obviously, a settype change any description to a value and quite surely a zero value.
Post Reply