MySQL diziye sonuçları (PHP)

0 Cevap php

Nasıl (mysql_fetch_array itibaren) mysql sonuçları böyle bir forma dönüştürebilirsiniz?

$some = array(
     "comments" => array(
         array( "text" => "hi", "id" => "1" ),
         array( "text" => "hi", "id" => "2" ),
         array( "text" => "hi", "id" => "3" ),
         array( "text" => "hi", "id" => "4" )
    )
);

: db gibi görünüyor ise

comments

id  text
1   blabla bla
2   bla bla

i've tried to fetch the values with foreach/while and insert it into two arrays but no success...

$some = array(
    "comments" => array()
);

$q = $mysql->sf('*', TBL_QST);
foreach($mysql->fetch($q) as $row) {
    $some[] = $row;
    // $some["comments"][] = $row;
}

0 Cevap