- Where Developers Learn, Share, & Build Careers


The way I thought it was not working here are my classes:

 < Code> class app {public $ db; Public function __ composition ($ db) {$ this- & gt; Db = $ db; }} Class analysis app {public $ analysis_id; Public function __ composition ($ analysis_id) {$ this- & gt; Analysis_id = $ analysis_ID; }} Class standard expansion extends (public work __ compositions ($ analysis_id) {origin: __ generation ($ analysis_id);}}   

$ db my database (Mysqli) is the object that I have passed in app class.

When I try to do a new standard analysis, I start it like this:

 < Code> $ analysis = new standard ($ analysis_ID);   

To get meta data about an analysis in the analysis class One of the methods, while the standard class is involved in ways to retrieve calculations for that specific type of analysis. I thought I would be able to use the $ db object, but I Analysis or standard class. Do I have to pass the standard code to the $ db object when I start it?

your analysis The father, app needs to call the constructor. It does not come by default because there is a parameter of $ db a app constructor, you have to pass it to subclass, and then click parent> __ construct ($ db) to analysis constructor.

Correct code:

  class app {public $ db; Public function __ composition ($ db) {$ this- & gt; Db = $ db; }} Class analysis app {public $ analysis_id; Public function __ conversion ($ analysis_id, $ db) {$ this- & gt; Analysis_id = $ analysis_ID; Parents :: __ Construction ($ Database); }} Square standard extension expands {public function __ conversion ($ analysis_id, $ db) {origin: __ generation ($ analysis_id, $ db); }} $ Analysis = new standard ($ analysis_id, $ db);    

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -