Native sql query returns a result set processing method

Today bloggers write native queries, we found that the data is not actually check out my data table, but an object

object(mysqli_result)#2 (5) {
["current_field"]=>
int(0)
["field_count"]=>
int(8)
["lengths"]=>
NULL
["num_rows"]=>
int(6)
["type"]=>
int(0)
}

I asked a wave of your mother only to find it was a normal return, db library is through the framework of the package, when the return has been the result set before returning the converted wave

But the question is how can we turn him into an array of it, we can not read the result set will not use ah, bloggers asked Ever since a wave of your mother

Finally found the answer: Attach Code

    The require ( './db.php' );
     $ SQL = "wx_menu_bar from the SELECT *" ;
     // top-level menu bar 
    $ menu_bar = $ db -> Query ( $ SQL );
     $ the Result = Array ();
     IF ( $ menu_bar ) {
         // converted to an array of 
      the while ( $ value = $ menu_bar -> fetch_array ()) {
                 $ Result [] = $ value ; 
         } 
    } 
    echo json_encode ( $ Result , JSON_UNESCAPED_UNICODE); Die;

Guess you like

Origin www.cnblogs.com/junyi-bk/p/12146174.html