Welcome Guest, Not a member yet? Register   Sign In
cant load database library into my own class
#1

[eluser]almarem[/eluser]
Hi,

i am trying to write my own class.

Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$CI =& get_instance();
$CI->load->library(array('database'));

Class Menu {}

Error messsage: unable to load the requested class. Do i have to write a menu model and load that into my class? i tried to load an another library(session) that works fine

david
#2

[eluser]InsiteFX[/eluser]
Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Menu
{
    private $CI;

    public function __construct()
    {
        $this->CI = get_instance();

        $this->CI->load->library('database');
    }

}
#3

[eluser]almarem[/eluser]
still have the same error message
#4

[eluser]InsiteFX[/eluser]
You say your getting an error but you have not post what the error is that your getting!

Also it's best to autoload the database in ./application/config/autoload.php

Then you can just get the CI instance and do a $this->CI->db
#5

[eluser]almarem[/eluser]
i wrote : unable to load the requested class.

but i found the solution:

$this -> CI -> load -> database();

thanks for your help anyway




Theme © iAndrew 2016 - Forum software by © MyBB