Which is faster? Fetching array with mysqli prepared statement:
$statement=$mysqli->prepare("SELECT `name`,`age` FROM `users` WHERE `id`=?");
$statement->bind_param('i',$id);
$statement->execute();
$statement->bind_result($array['0'],$array['1']);
$statement->fetch();
return $array;
Or fetching array with mysqli only:
return $mysqli->query("SELECT `name`,`age`FROM `users` WHERE `id`='".$id."'")->fetch_row();
EDIT: Use only prepared statements, because normal queries are NOT SAFE! Do not worry about performance – worry about security!
EDIT2: Recently I started using PDO instead of MySQLi. PDO is better than MySQLi extension in many ways. One of them is fetching and looping through a multidimensional array.
There is a strict rule: bother yourself with performance questions only if you have strong reason to.
Otherwise you would either just waste your time or even make things worse.
In your particular case, a difference, even if exists, would be hardly noticeable.
So, it’sproper design should be your concern, not imaginable “performance issue”.