Question about "-"

0

Good morning, I have the following code snippet:

$sql = "SELECT * FROM users WHERE user_name = '" . $user_name . "' OR user_email = '" . $user_email . "';";
            $query_check_user_name = $this->db_connection->query($sql);

db_connection would be: $this->db_connection = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);

My question is, does the variable $query_check_user_name get the variable db_connection for the current instance that receives query ($ sql)?

How would that go without the "- >"? And with the "- >" How does the process work? (who gets who)

    
asked by anonymous 26.04.2016 / 15:01

1 answer

0

It will get the return of the query() method. Simply this.

Depends on the scope of your class, whether this method is __toString return or etc.

It is possible to return the instance of the class by giving return $this in the invoked method.

I did not quite understand the doubt to be honest, it was poorly formatted. But what I understood, I answered.

When invoking

$query_check_user_name = $this->db_connection->query($sql);

You're basically saying:

PHP, all good?

I need you to access object db_connection of this class, this object will have another instance, in that instance you will invoke method query and inform $sql as argument. The return of query() you store for me in the variable $query_check_user_name please.

    
26.04.2016 / 15:19