1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Loading MySQL Provider.

Discussion in 'Development' started by DiamondGamer30, Jul 22, 2018.

  1. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I'm trying to load my MySQL provider file but there seem to be 2 errors every time. I'm currently using a virion called libasynql.

    Error 1:
    Code:
    22.07 12:53:59 [Server] Server thread/CRITICAL TypeError: "Return value of core\provider\MySQLProvider::getDatabase() must be an instance of poggit\libasynql\DataConnector, null returned" (EXCEPTION) in "PlexFac/src/core/provider/MySQLProvider" at line 48
    
    Code to it:
    PHP:
    public function __construct(Core $core) {
        
    parent::__construct($core);
        
    $config $core->getConfig()->get("database");
        
    $this->database libasynql::create($core$config, [
            
    "mysql" => "mysql/queries.sql"
        
    ]);
        
    $this->init();
    }

    public function 
    getDatabase(): DataConnector {
        return 
    $this->database// Line 48
    }

    Error 2:
    Code:
    22.07 12:53:59 [Server] Server thread/CRITICAL TypeError: "Return value of core\Core::getProvider() must be an instance of core\provider\MySQLProvider, null returned" (EXCEPTION) in "PlexFac/src/core/Core" at line 176
    
    Code to it:
    PHP:
    public function onEnable() {
        
    // Making folders and saving resources
        
    $this->provider = new MySQLProvider($this);
    }

    public function 
    onDisable() {
        
    $provider $this->getProvider();
        
    $provider->getDatabase()->close();
    }

    public function 
    getProvider(): MySQLProvider // Line 176
        
    return $this->provider;
    }
    Configuration file:
    PHP:
    database:
        
    typemysql

        host
    127.0.0.1
        username
    root
        password
    admin
        schema
    Database
     
    Last edited: Jul 22, 2018
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Are there other errors above them? It seems that your plugin crashed before the database is created, and the errors are from onDisable.
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    $this->database should be something like new DataConnector(stuff there)
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Yes, and it is in the libasynql code. Most likely libasynql threw an exception that crashed your plugin, but you didn't check it.
     
  5. DiamondGamer30

    DiamondGamer30 Baby Zombie

    Messages:
    175
    GitHub:
    diamondgamermcpe
    I'm unsure if libasynql even loaded. It didn't state that libasynql was loaded in the loggers, which I think it's supposed to.
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Are you sure there is no other error messages?

    Also, are you using devirion, or are you using a packaged phar?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.