Code: Select all
$result = $mysqli->query("SELECT * FROM foo WHERE id='bar'");
while ($row = $mysqli->fetch_array($result)){
echo "foo: ".$row['foo']."</br>";
echo "bar: ".$row['bar'];
}
Code: Select all
public function execute($unprp_stmt, $data){
//Prepare the stmt, $this->con is the mysqli-object
$stmt = $this->con->prepare($unprp_stmt);
//Get dynamically built parameter string for the bind_param method. E.g. 'issis'
$paramstr = $this->get_paramstr($data);
// Dynamically build up the arguments for bind_param
$params = array();
$params[] = $stmt;
$params[] = $paramstr;
foreach($data as $k => $v){
$params[] = &$data[$k];
}
// and then call bind_param with the proper arguments
call_user_func_array('mysqli_stmt_bind_param', $params);
$stmt->execute();
//So far everything works as it should, it's the following part which I cannot understand how to make it work.
//As you can see is it a direct implementation of the other user's post and I don't really understand how his
//function is supposed to work.
$meta_data = mysqli_stmt_result_metadata($stmt);
//print_r($meta_data);
$fields = array();
$out = array();
$fields[0] = $stmt;
$count = 1;
while($field = mysqli_fetch_field($meta_data)) {
$fields[$count] = &$out[$field->name];
$count++;
}
//print_r($fields);
call_user_func_array('mysqli_stmt_bind_result', $fields);
return $stmt;
}