Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6472451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:20:47+00:00 2026-05-25T06:20:47+00:00

The following is my simplified code <?php $database = new db(); $file = new

  • 0

The following is my simplified code

<?php
  $database = new db();
  $file = new file();
  $input = new input();
  $output = new output();

  $data = "SELECT * FROM table;";
  $input->page($data);

  class db {
        public function queryExecute($var) {
              $var = $this->queryEncode($var);
              $var = $this->querySubmit($var);
        return $var;
        }

        public function queryEncode($var) {
              // Do somthing
        return $var;
        }

        public function querySubmit($var) {
              // Do somthing
        return $var;
        }
  }

The issue is when I add this to the code:

  class input {
        public function page($data) {
              // Do something
              $pageQuery = db::queryExecute($data);
        }
  }

With this, there are two things I have to do. First, I have to hide the errors for the db::queryExecute($data); code if the server is set to strict. And now for the second problem. I can’t seem to use this line of code (which is the only way I have yet found possible for referencing other classes besides using Abstract) if the class that is being referenced is referencing yet another class but this time within it’s own class.

For better explanation, the procedure is as follows:

  1. Grab the $data variable and send it to the $input->page() function ( $input->page($data) ).
  2. Referencing the db class, the $input->page() function sends the information onto the $database->queryExecute() function by means of the db::queryExecute() format ( db::queryExecute($data) ).
  3. But because we are using the ::, when $database->queryExecute() references $database->queryEncode() and $database->querySubmit() using $this-> operator ( $this->queryEncode() and $this->querySubmit() ), $this-> currently belongs to $input-> and not $database->.

So what’s the solution… Reference the other class differently (instead of ::)? Use a $_GLOBAL variable when I define my classes? Use something other than $this->? Configure all of the classes to use ABSTRACT/EXTENDS (or INTERFACE)?

The following error outputted refers to $var = $this->queryEncode($var);:

Fatal error: Call to undefined method input::querySubmit() in C:\[...]\global.php on line 12

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:20:47+00:00Added an answer on May 25, 2026 at 6:20 am

    Do not make static call to not static function. Pass $db instance to page, or provide global access to the database (via global registry, singleton or other method). But best, pass the dependency – the database instance, to the method.

    <?php
      $database = new db();
      $file = new file();
      $input = new input($database);
      $output = new output();
    
      $data = "SELECT * FROM table;";
      $input->page($data);
    
      class db {
            public function queryExecute($var) {
                  $var = $this->queryEncode($var);
                  $var = $this->querySubmit($var);
            return $var;
            }
    
            public function queryEncode($var) {
                  // Do somthing
            return $var;
            }
    
            public function querySubmit($var) {
                  // Do somthing
            return $var;
            }
      }
    
      class input {
        protected $_database;
        public function __construct($database) {
            $this->_database = $database;
        }
        public function page($data) {
              // Do something
              $pageQuery = $this->_database->queryExecute($data);
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no control over database schema and have the following (simplified) table structure:
I have the following code(simplified). public class OrderProcessor { public virtual string PlaceOrder(string test)
I'm experiencing an intermittent deadlock situation with following (simplified) code. DataSet my_dataset = new
I have the following code (simplified) int main() { ifstream myFile(input.txt); if(myFile.is_open()) cout<<test; }
I have some PHP code like the following (simplified): <ul> <?php for ($Index =
I have the following (simplified) code: IDbConnection connection = new SQLiteConnection(GetConnectionString()); if (connection.State ==
Imagine I have the following code (simplified regarding my real context of course): <div
I'm using gcc 4.3.2. I have the following code (simplified): #include <cstdlib> template<int SIZE>
I am debugging some code and have encountered the following SQL query (simplified version):
The following code is a simplified version of what I use for event dispatching.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.