Selecting mysql data with php array not working -


for reason code isnt working , dont know why:

$action = array('id', 'lurl', 'account'); $request = 3; $stm = $pdo->prepare("select ? (select * urls order id desc limit ?) sub order id asc"); $stm->bindvalue(1, implode(',', $action)); $stm->bindvalue(2, $request, pdo::param_int); $stm->execute(); $data = $stm->fetchall(); 

all return following array:

array ( [0] => array ( [id,lurl,account] => id,lurl,account ) [1] => array ( [id,lurl,account] => id,lurl,account ) [2] => array ( [id,lurl,account] => id,lurl,account ) ) 

but when manually enter data in query so:

select id,lurl,account (select * urls order id desc limit 3); 

it supposed to. know why is?

with bindvalue can bind "values" , not references. bind references need use bindparam

change:

$stm->bindvalue(1, implode(',', $action)); $stm->bindvalue(2, $request, pdo::param_int); 

to:

$stm->bindparam(1, implode(',', $action)); $stm->bindparam(2, $request, pdo::param_int); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -