php - mysqli get_result alternative with multiple parameters -


select * `ware_house_indents` `has_cancel` = ? , `eid`= ?  

i need result above query in mysqli. cant use get_result() function because not working in server.i have found below function , working fine.but function not possible pass multiple parameters.please me solve problem.

function db_bind_array($stmt, &$row) {     $md = $stmt->result_metadata();     $params = array();     while($field = $md->fetch_field()) {         $params[] = &$row[$field->name];     }     return call_user_func_array(array($stmt, 'bind_result'), $params); } function db_query($db, $query, $types, $params) {     $stmt = $db->prepare($query);     $bindret = call_user_func_array(array($stmt,'bind_param'),                                     array_merge(array($types), $params));     $stmt->execute();     $result = array();     if (db_bind_array($stmt, $result) !== false) {         return array($stmt, $result);     }     $stmt->close();     return false; } if (($qryres = db_query($mysqli, $sql, 'i', array(&$var))) !== false) {     $stmt = $qryres[0];     $row = $qryres[1];     while ($stmt->fetch()) {         print_r($row);     }     $stmt->close(); } 

let me suggest quite indirect solution.
you'd huge favor if start using pdo instead of mysqli

it has no mysqli disadvantages when dealing prepared statements has way better implementation of above functions out of box. so, let data in few lines:

$sql = "select * ware_house_indents has_cancel = ? , eid= ?"; $stm = $pdo->prepare($sql); $stm->execute(array($cancel,$eid)); $data = $stm->fetchall(); // or fetch() if need 1 row 

that's all


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -