0
votes

I'm having an issue with a set of code. I'm not able to get the variable to display.

Here is the function

    public function __construct($id = self::DHMeetingCommentCardNew, DHMeetingGroup $meetingGroup = null)
    {
        global $DB;

        if ($id == self::DHMeetingCommentCardNew)
        {
            var_dump($meetingGroup);
            $query = "INSERT INTO `" . self::DHMeetingCommentCardTable . "` (`UniqueID`, `MeetingGroup`) VALUES (UUID(), '{$meetingGroup['_id']}')";
            $DB->query($query);

            $this->_id = $DB->lastID();
            $this->_initializeNewCommentCard();
        }
        else
        {
            $this->_id = intval($id);
        }
    }

I can't get the ID out of the $meetingGroup variable.

For the var_dump($meetingGroup) it dumps this.

NULL object(DHMeetingGroup)#10745 (1) { ["_id":"DHMeetingGroup":private]=> int(11086) }
2

2 Answers

0
votes

As long as property is defined as property you can only access it from the same instance (and same class), not outside.

The only thing you can do is to change how _id property is declared in DHMeetingGroup from private to public

0
votes

try adding this code to your class DHMeetingGroup

public function get_id()
{
    return $this->_id;
}

and then changing this row (in the class i'm guessing is called DHMeetingCommentCard)

$query = "INSERT INTO `" . self::DHMeetingCommentCardTable . "` (`UniqueID`, `MeetingGroup`) VALUES (UUID(), '{$meetingGroup['_id']}')";

to

$query = "INSERT INTO `" . self::DHMeetingCommentCardTable . "` (`UniqueID`, `MeetingGroup`) VALUES (UUID(), '{$meetingGroup->get_id()}')";