Welcome Guest, Not a member yet? Register   Sign In
[help] Unable to load the requested class: database
#1

[eluser]Wilianto Indrawan[/eluser]
Hello, I'm newbie with codeigniter.

I try to make my own library on CI, but I get "Unable to load the requested class: database" error in my browser. Below is my code:

Code:
Class CI_Gettag {
    var $ci;
    
    function __construct() {
        $ci =& get_instance();
    }
    
    function save_tag($tag_name, $table, $coloumn){
        $tag = strtolower($tag_name);
        $tag = preg_replace("/[^a-z0-9 ]/", "", $tag);
        $tag = str_replace("  ", "", $tag);
        $tag = str_replace(" ", "-", $tag);
        
        $sql = "SELECT * FROM $table WHERE $coloumn = '$tag'";
        
        if($this->ci->db->query($sql)->num_rows > 0){
            for ($i = 2; $i < 1000; $i++){
                $tag .= "-".$i;
                
                $sql = "SELECT * FROM $table WHERE $coloumn = '$tag'";
                if($this->ci->db->query($sql)->num_rows == 0){
                    $i = 1000;
                }
            }
        }
        
        return $tag;
    }
}

I'm also load the database library on autoload.php.

May I use the database class on my own library.

Thank You

#2

[eluser]Wilianto Indrawan[/eluser]
problem solved

http://ellislab.com/forums/viewthread/104541/#526583

Thank you.
#3

[eluser]InsiteFX[/eluser]
CI is a CodeIgniter reserved word and you should not be using it in your own Classes!
#4

[eluser]CroNiX[/eluser]
What @InsiteFX means is using CI_ for the prefix of your class name is a no no, not using "ci" as a property in your class. CI_ only belongs on stock core CI classes and libraries, not ones you create. It has special meaning.

var $ci; is also php4 way of declaring variables.




Theme © iAndrew 2016 - Forum software by © MyBB