Return results from mysql, using user functions
===

Please tell, why this code is wrong?

    function myres () {
	   $db = new mysqli("localhost","userrr","pass","mvc");
	   $res = $db->query("SELECT * FROM news ");
	   return $res;
    }


    while ($row = myres()->fetch_row()) {
	    echo  $row[0];
    }

P.S.
this code is working:

    $db = new mysqli("localhost","userrr","pass","mvc");
    $res = $db->query("SELECT * FROM news ");
    while ($row = $res->fetch_row()) {
	    echo  $row[0];
    }