Liquid Fire Posted July 24, 2007 Share Posted July 24, 2007 I have a class called data which every data class is going to extend from. The 3 things is data class in 2 method(get, save) and then the member $_data_map. The 2 function will help me get data from the database and insert in into a class and then using the data in the class, to save the data or update that data in the database, it will be using the $_data_map variable which will hold the database name which will point to an array the hold the class member name along with other things(like error code, default override value, etc...). My question is can i access the user $_data_map in the parent class by using self::(because the call is technically coming from the user class not the data class) or do i need to pass the $_data_map to the function? Link to comment https://forums.phpfreaks.com/topic/61539-question-about-self/ Share on other sites More sharing options...
Liquid Fire Posted July 24, 2007 Author Share Posted July 24, 2007 Thinking about it, i am just going to create the query statement inside the user get method and then pass it to the data get method, I need to do is like this anyways but would still like to know about this topic. Link to comment https://forums.phpfreaks.com/topic/61539-question-about-self/#findComment-306274 Share on other sites More sharing options...
Liquid Fire Posted July 24, 2007 Author Share Posted July 24, 2007 Well the query thing is a separate issue so any help won this would be great. Link to comment https://forums.phpfreaks.com/topic/61539-question-about-self/#findComment-306611 Share on other sites More sharing options...
Buyocat Posted July 25, 2007 Share Posted July 25, 2007 I'm not sure I follow you. If $_data_map belongs to the children and not the parent then you won't be able to access it through self:: or $this-> you'll have to pass it to the parent through a virtual method. However if every class uses $_data_map then that may suggest moving it into the parent class and either restricting its access completely in the children (For instance you could expose a protected Add and Remove method in the parent to interact with the state), or you could jsut make it protected. Link to comment https://forums.phpfreaks.com/topic/61539-question-about-self/#findComment-306883 Share on other sites More sharing options...
Liquid Fire Posted July 25, 2007 Author Share Posted July 25, 2007 I figured i would have to pass it. Every data class does use $_data_map which is why it is in the parent class "data" hoever each child class needs it to hold different information. thanks i know i have to pass it to the parent class. Link to comment https://forums.phpfreaks.com/topic/61539-question-about-self/#findComment-307050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.