doushi4795 2015-01-16 15:09
浏览 101

PHP:如何从2个对象合并和设置方法

I have case study where I should display data from 3 table.

  1. User_Card Table

  2. Card Table

  3. Category Table

The query :

SELECT user_card_id, card_name, category FROM .... WHERE...

The query going well...

But when I try to set the selected data on setter, I have a little problem.. this is my code when I try to set.

                $cards = array();
                while($stmt->fetch())
                {   
                    $card = new UserCard();
                    $card->setUserCardId($user_card_id);
                    $card->setCardName($card_name);
                    $card->setCategory($category);
                    array_push($cards, $card);
                }

                $stmt->close();
                return $cards;

The code hint error because setCardName() and setCategory() is not on UserCard() object.

is that any way to do this without doing inheritance in UserCard object ?

update : **setCategory() is a member in Category Class

setCardName() is a member in Card Class should I merge it ?**

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求TYPCE母转母转接头24PIN线路板图
    • ¥100 国外网络搭建,有偿交流
    • ¥15 高价求中通快递查询接口
    • ¥15 解决一个加好友限制问题 或者有好的方案
    • ¥15 急matlab编程仿真二阶震荡系统
    • ¥20 TEC-9的数据通路实验
    • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
    • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
    • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
    • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型