pdo-database-class icon indicating copy to clipboard operation
pdo-database-class copied to clipboard

Fatal error: Call to a member function execute() on null

Open usmanawaan opened this issue 7 years ago • 0 comments

When i open a link localhost/web/newpanel/auth/login the below error shown please tell me what's wrong in my code please check below error and my files.

Fatal error: Call to a member function execute() on null in F:\Ampps\www\web\newpanel\Application\Libs\PDODb.php on line 972

Directory Structure Application -Controllers --Auth.php -Core --Modal.php -Libs --PDODb.php -Modals --AuthModal.php

My Application use SplAutoload function for autoload classes

/********** Application/Controllers/Auth.php file start *******/

<?php
namespace Application\Controllers;
use \Application\Models\AuthModel;
class Auth extends MainController
{
	function __construct($root_params="")
	{
		parent::__construct();
		$this->authModel = new AuthModel();
		$this->root_params = $root_params;
	}
	public function login()
	{

		$data = $this->authModel->selectAll();
		var_dump($data);
		exit;
		
	}
}

/********** Application/Controllers/Auth.php file end *******/

/********** Application/Modals/AuthModal.php file start *******/

<?php
namespace Application\Models;
use \Application\Core\Model as MainModel;
class AuthModel extends MainModel
{
	public function __construct(){
		$this->table = "users";
	}
}

/********** Application/Controllers/Auth.php file end *******/

/********** Application/Core/Modal.php file start *******/

<?php
namespace Application\Core;
use \Application\Libs\PDODb;
class Model
{
    private static function getDB()
    {
        
        $db = new PDODb('mysql','localhost', 'root', 'mysql', 'newpanel');
        return $db; 
        
    }

    public function selectAll()
    {
        $db = static::getDb();
        $result = $db->get("activitylog");
        
        return $result;
    }
}

/********** Application/Core/Modal.php file end *******/

usmanawaan avatar Dec 29 '18 05:12 usmanawaan