I’m using a dynamic bind_parm , which is:
public function get_result($sql,$types = null,$params = null) {
$stmt = $this->mysqli->prepare($sql);
if($types&&$params)
{
$bind_names[] = $types;
for ($i=0; $i<count($params);$i++)
{
$bind_name = 'bind' . $i;
$$bind_name = $params[$i];
$bind_names[] = &$$bind_name;
}
$return = call_user_func_array(array($stmt,'bind_param'),$bind_names);
}
$stmt->execute();
# these lines of code below return one dimentional array, similar to mysqli::fetch_assoc()
$meta = $stmt->result_metadata();
while ($field = $meta->fetch_field()) {
$var = $field->name;
$$var = null;
$parameters[$field->name] = &$$var;
}
call_user_func_array(array($stmt, 'bind_result'), $parameters);
while($stmt->fetch())
{
$this->handler ($parameters); // Handle queried results
}
$stmt->close();
}
However , i’m unable to retrieve that how many rows were selected during last operation , i tried $mysqli->affected_rows , which’s always -1; And $mysqli->num_rows was inaccessible , it was undefined in $mysqli.
I think putting an variable inside that loop to count it is unnecessary , does anyone have a suggestion ?
Many thanks !
You can use