mysql pdo binding with less than operator

tyuret used Ask the Experts™
I have a select function like this

function selectsqlpn($sql,$arr) {
      global  $dbpdo;
      $q = $dbpdo->prepare($sql);
      $q-> execute($arr);
      $r = $q ->fetchAll();
      return $r;

And I make the query like this

$sql="Select * from TABLE where A<? ";

The result is equal to
$sql="Select * from TABLE where A<'6' ";

But I want it like this
$sql="Select * from TABLE where A<6 ";

So how will I bind it?

Thank you.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can use BindParam for that

This is an example from PHP Manual

/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories < ? AND colour = ?');
$sth->bindParam(1, $calories, PDO::PARAM_INT);
$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial