Database results as objects or arrays?

前端 未结 4 732
礼貌的吻别
礼貌的吻别 2020-12-17 17:48

This question is similar to Mysql results in PHP - arrays or objects? However, my question expands on what has been discussed there.

I\'m trying to decide which form

4条回答
  •  情歌与酒
    2020-12-17 18:33

    I think you are talking about weird objects coming up using SELECT on two or more tables.

    I solve this by using AS in my sql to give it a more simple name.

    SELECT IFNULL(SUM(table2.big_name),0) AS sumBig
    
    ...
    
    
    $result=$PDO->fetchObject();
    $sum=$result->sumBig;
    

提交回复
热议问题