连接两个表并获取两个数组中的结果

时间:2015-04-23 01:10:56

标签: php arrays join mysqli

我有两张桌子并通过groupid加入:

$UserInfo= db::Query("SELECT g.* AS GroupPer ,u.* As Userinfo ,
(SELECT COUNT(m.id) FROM     ".DATABASE_TP_PREFIX."comments m  WHERE  m.userid =u.userid ) AS totalcomments
FROM ".DATABASE_TP_PREFIX."user u LEFT JOIN ".DATABASE_TP_PREFIX."userprofile p ON u.userid=p.parentid
LEFT JOIN ".DATABASE_TP_PREFIX."groups g ON g.id=u.groupid
WHERE u.userid=".$Userid."");

我需要获取结果为两个数组(上面的结果是一个数组) 例如:

$this->Info = db::fetch_array($UserInfo,'assoc');       // user info
$this->Permission = db::fetch_array($UserInfo,'assoc'); // user Permission
像这样

array (
    array[0] (
        username => Manour,
        email    => Eimaidwra@zzzz.com
    )
    array[1] (
        group_tite      => Administer,
        permissonaccess => 1
    )
)

0 个答案:

没有答案