The solution from Daan is very nice! For this, i have to say thank you!
The point is, that i had, based on this, developed a class which works with mysqlnd, when it's there and Daan's alternative when it's missing.
I have built in fetchAssoc, fetchAllAssoc/Array, num_rows as methods. It's still in development and part of youphptube. This maybe also helps Ehab (whish for fetchAssoc).
https://github.com/DanielnetoDotCom/YouPHPTube/blob/master/objects/mysql_dal.php
Usage:
$sql = "SELECT * FROM users WHERE id = ?";
$res = sqlDAL::readSql($sql,"i",array($users_id));
$fullData = sqlDAL::fetchAllAssoc($res);
// $data = sqlDAL::fetchAssoc($res); $data2 = sqlDAL::fetchAssoc($res); // or like this
// $countedRows = sqlDAL::num_rows($res); // or like this
sqlDAL::close($res);
I would made this as a sub-post to Daan's answer, but my reputation is too small.