0

Hi built an library to deal with Ms Sql querys in CI4. Stored in Libraries folder

<?php 
namespace App\Libraries;

class Mssql
{
    /* default values */

    private $connection  = null;
    private $server = "";
    private $database = "";
    private $user = "";
    private $password = "";
    private $port = "";

    const ICONV_TRANSLIT = "TRANSLIT";
    const ICONV_IGNORE = "IGNORE";
    const WITHOUT_ICONV = "";

    public function __construct()
    {
        die("Just entered in lib Mssql");
        /*$db = new Database();
        $this->server = $db->mssqlServer;
        $this->database = $db->mssqlDatabase;
        $this->user = $db->mssqlUser;
        $this->password = $db->mssqlPassword;
        $this->port = $db->mssqlPort;*/
    }

I want it to autoload when the app starts so I edited the autoload.php file like this

    public $psr4 = [
        APP_NAMESPACE => APPPATH, // For custom app namespace
        'Config'      => APPPATH . 'Config',
        'Libraries'   => APPPATH . 'Libraries',
    ];

    
    public $classmap = [
        'Mssql' => APPPATH . 'Libraries/Mssql.php',
    ];

I think that I should see "Just entered in lib Mssql" when entering in the home controller but it do nothing... Can someone point me what I am doing wrong? I dont want to type use App\libraries\Mssql in every single model file that I have

  • Does this answer your question? [How to autoload codeigniter4 library once and access it every where in Controller, Model, View like in CI3](https://stackoverflow.com/questions/61518921/how-to-autoload-codeigniter4-library-once-and-access-it-every-where-in-controlle) – steven7mwesigwa Apr 07 '23 at 09:21
  • [How to autoload helper functions in codeigniter 4](https://stackoverflow.com/questions/41777261/how-to-autoload-helper-functions-in-codeigniter-4) – steven7mwesigwa Apr 07 '23 at 09:24
  • [CodeIgniter 4: Autoload Library](https://stackoverflow.com/questions/58900176/codeigniter-4-autoload-library) – steven7mwesigwa Apr 07 '23 at 09:27

0 Answers0