Organizational Research By

Surprising Reserch Topic

how can i pass an array of pdo parameters yet still specify their types


how can i pass an array of pdo parameters yet still specify their types  using -'php,mysql,pdo'

$sql = "SELECT * FROM table WHERE id LIKE CONCAT('%', :id, '%')
LIMIT :limit1, :limit2";


I want to still use the array input like this:

$stmt->execute($array);


Otherwise I cannot reuse the same method for executing my queries.

At the same time, the :limit1 and :limit2 doesn't work unless it is put in like this:

$stmt->bindParam(':limit1', $limit1, PDO::PARAM_INT);


I tried to do both but it doesn't execute with the bindParams:

$stmt->bindParam(':limit2', $limit2, PDO::PARAM_INT);
$stmt->execute($array);


What is the way around it?

I thought I could extend PDOStatement and add a new method "bindLimit" or something but I can't figure out what internal method PDO uses to bind parameters to a variable.
    
asked Oct 19, 2015 by ajit.chavhan
0 votes
2 views



Related Hot Questions



Government Jobs Opening


...