How to read this expression/what does it mean?

Hi folks,
am new to php and i was going through code error and i had error on a line which says

 $row = $this->_data[0];

i don’t know how to read this or what is that and what is going on here. can anyone explain what is this?

I thought of that too and while i waited for your reply i was putting if statement with isset as gvre said (thanks gvre) and the logic which came into my mind was same as u mentioned that user might have not filled the fields.
Thanks for the help guys ! :slight_smile:

Interesting function that one. It does

		if (isset($this->_data[0]))

        $row = $this->_data[0]; 

but doesnt give an else… so it’s expecting data to have been returned by the buildQuery and getList…

buildQuery on pay_info should query out

SELECT * FROM #__br_user WHERE user_id=" . $this->_user_id

(Not sure what #__br_user means in this context, but it seems to be a Joomla templating fixer)

Only thing i can think of at this point is check your database to see if said table has any data for that user?

and which function are you calling that generates this error?


where variables are assigned to $row

To what i can comprehend is that if user doesn’t have any info like data information this error pop up.?

here is text file of that php file

EDIT: or better, is there somewhere we can find this class you’re using?

so it doesnt fill in the data at all… unless it’s parent class does

is there an add data function?

here in the construct function

    function __construct() {
        global $mainframe, $option;
        $user = & JFactory::getUser();
        $this->_myuser = & $user;
        $this->_user_id = $user->id;

        //echo "<br>".$user->name;exit;

What does the constructor function define _data with?

as i am newbie so don’t know about classes n constructor. what i understand from what ur saying is to look for a function __construct(found that) in which data has been defined or called?

Without seeing the class definition of the object in question, it will be hard to answer your question, but;

Check the Constructor of the class (function __construct) to see if it puts any data into _data[0] by default.

If so, we’ll need to see the whole class cause something’s going wrong. (Stop here.)
If not, check to see if there’s a method to add a row of data to the object. (Continue below)

If not, you’ve got a very bad class.
If so, you’ll need to add data to the object before trying to call whatever method you’re describing above.

code itself is very long, However i can post few line which jump error to next one.

        if (isset($this->_data[0]))
        $row = $this->_data[0]; 
        //$row = $this->_data[0];
         $id = $row->id;
         $user_id = $row->user_id;
          $name = $row->name;
          $subscriptionId = $row->subscriptionId;
          $customerPaymentProfileId = $row->customerPaymentProfileId;

thats the code,How do i know if $row is set or check its value b4 it get to these lines?

My wild guess is that maybe its a local variable and not global? if so how can i see what’s going on and if its local or global? any string or array function i can use?

Could you post the source code?

“What does it mean”.

The line reads as:

Assign to $row the value of this object’s _data array (the _ at the start indicates that this element is considered “Private” to the object), pulling from the first element of the array.

Based on it being assigned to something called $row, i’m assuming _data[0] is itself an array.

That helped, but the error moves on to the next $row and so on. how do i track this bug so that if $row doesn’t exist it doesn’t show at all. more important how do i get to read the my posted query in plain English

I suppose that _data[0] does no exist. You should check if _data array has members.

if (isset($this->_data[0]))
        $row = $this->_data[0];