Clandestinex337 Posted June 25, 2011 Share Posted June 25, 2011 I understand what $this->db means, its accessing the variable db, but when you add the extra -> to the end what does that do? Its very hard to research information on this since Google doesn't help to much when using -> in the search. Thanks Link to comment https://forums.phpfreaks.com/topic/240400-what-does-this-mean-in-oop-this-db-query/ Share on other sites More sharing options...
wildteen88 Posted June 25, 2011 Share Posted June 25, 2011 Its just calling the query function within the database object ($this->db). I think this is known as object chaining. Link to comment https://forums.phpfreaks.com/topic/240400-what-does-this-mean-in-oop-this-db-query/#findComment-1234795 Share on other sites More sharing options...
Clandestinex337 Posted June 25, 2011 Author Share Posted June 25, 2011 Thanks, that makes sense. Instead of making another post, I will just put it in here. The other part of the code I am trying to learn has public function __construct(MySql $db, $id = 0) I am confused on the MySql $db. Does it give the class MySql = $db? Thanks again! Link to comment https://forums.phpfreaks.com/topic/240400-what-does-this-mean-in-oop-this-db-query/#findComment-1234796 Share on other sites More sharing options...
wildteen88 Posted June 25, 2011 Share Posted June 25, 2011 That is called type hinting. Which mean it is enforcing that the $db argument must be an instance of the MySQL object when the parent class is initiated. Link to comment https://forums.phpfreaks.com/topic/240400-what-does-this-mean-in-oop-this-db-query/#findComment-1234801 Share on other sites More sharing options...
Clandestinex337 Posted June 25, 2011 Author Share Posted June 25, 2011 Thanks! Link to comment https://forums.phpfreaks.com/topic/240400-what-does-this-mean-in-oop-this-db-query/#findComment-1234802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.