0

I am trying to output a set of data, and I have, due to my LEFT OUTER JOIN got multiple rows per match.

I'm using a positive look ahead to see if the next row is the same id as the first. However the return from the database class returns an array of objects.

array(7) {
          [0]=> object(stdClass)#4 (8) {
                                      ["dom_id"]=>string(1) "3"
                                      ["domain"]=>string(11) "example.com"
                                      ["status"]=>string(7) "Invalid"
                                      ["expiry"]=>string(10) "2010-07-20"
                                      ["remaining"]=>string(6) "0 Days"
                                      ["rem_id"]=>NULL
                                      ["alert_type"]=>NULL
                                      ["contact"]=>NULL
  }
//etc

I am getting the following error, Fatal error: Cannot use object of type stdClass as array

My code is as follows,

echo $domains[$k+1]->alert_type;

I know that I could assign the new dimension to a variable and access that as an object, but for the sake of neatness I'd rather access it directly.

Is this possible? ..and if it is, how do I approach it?

Ta

2 Answers 2

2

Either

Sign up to request clarification or add additional context in comments.

1 Comment

Eish, I'll just assign it to a variable then :) Cheers for the reply
0

Assuming that $domains is your stdClass object which you wish was an array, you could try using variable variables:

echo $domains->{$k+1}->alert_type;

The real problem though is that you have a bunch of stdClass objects. Are you storing these in a session and then reading them later, or are you neglecting to include a file or something... ?

1 Comment

I don't think it's missing the database class, or my queries wouldn't work. It's just a straight up db -> display page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.