Welcome Guest, Not a member yet? Register   Sign In
library classes
#9

[eluser]jaswinder_rana[/eluser]
application/library/sample_lib.php (_lib is not important, Just used it here to have a unique class name)

- If you are on a UNIX system (or a case-sensitive system unlike Windows) then I suggest you use lower cases for file OR JUST FIRST character capital like Sample_lib.php

- Class's first character MUST be capital (not sure about the rest; same as filename I guess)

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Sample_lib{
  //Your code
}

application/controllers/Sample.php

Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Sample extends Controller{
function Sample(){
  parent::Controller(); //MUST Call it WHEN you use constructor in YOUR controller

  $this->load->library('Sample_lib');
  $this->Sample_lib->function();

  //OR
  $this->load->library('Sample_lib','something');
  $this->something->function();

}
}

This is how it works. I may have some syntax or logical error but other than this is the way I did it.

Hope this helps


EDIT: Shucks. Randy beat me to it. I agree, it may be your naming convention.


Messages In This Thread
library classes - by El Forum - 12-15-2008, 11:42 AM
library classes - by El Forum - 12-15-2008, 11:49 AM
library classes - by El Forum - 12-15-2008, 12:08 PM
library classes - by El Forum - 12-15-2008, 12:13 PM
library classes - by El Forum - 12-15-2008, 12:19 PM
library classes - by El Forum - 12-15-2008, 12:22 PM
library classes - by El Forum - 12-15-2008, 12:43 PM
library classes - by El Forum - 12-15-2008, 01:05 PM
library classes - by El Forum - 12-15-2008, 01:10 PM
library classes - by El Forum - 12-15-2008, 01:21 PM
library classes - by El Forum - 12-15-2008, 01:27 PM
library classes - by El Forum - 12-16-2008, 05:30 AM
library classes - by El Forum - 12-16-2008, 08:13 AM
library classes - by El Forum - 12-16-2008, 09:02 AM
library classes - by El Forum - 12-16-2008, 09:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB