PHP Object Oriented aproach

Hello, could you please explain me what does the following line of code means?
I don't understand the second line of the code.

function query($query) {

$this->theQuery = $query;
return mysql_query($query, $this->link);

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jagadishwor DulalSenior Web DeveloperCommented:
function query($query) is a function with a parameter $query. That means you must pass any query in the variable to run this function. your varibale $query may contain any query like. "Select * from sometable ORDER BY somefield" etc

In the second line $this->theQuery=$query passed the value to theQuery  variable for object.

In the third line return mysql_query($query, $this->link); execute the query using link which may already have defined to connect with database.
Loganathan NatarajanLAMP DeveloperCommented:
Have a look at this tutorial, Examples

$query can be assigned to $this->theQuery  ... it can be accessed as global on the entire class.

Just look at the link
Lukasz ChmielewskiCommented:
This function is part of the class

function query($query) {

$this->theQuery = $query;
return mysql_query($query, $this->link);


if you mean $this, it says, that there is also a variable
var $theQuery in the same class, passing the $query through that function as an argument sets THIS class' variable value to a given $query.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ludwig DiehlSystems ArchitectCommented:
Line1: assigns $query to theQuery which is a class variable
Line2: returns a mysql recordset which can be fetched

krutarth941Author Commented:
It was helpful.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.