[eluser]onejaguar[/eluser]
The short answer:
If you want to use a library in your model's constructor you either have to load it in the controller before you load the model, or better yet use
Code:
$CI =& get_instance();
$CI->load->library("MyLib");
$CI->mylib->setSomething("some value");
Long Answer:
The reason is that CodeIgniter manually copies references to all the loaded libraries so that the model can access them with $this->. When a model is created, the "_assign_libraries()" method is called, assigning all currently loaded libraries to the model. Likewise whenever you load a library the function "_ci_assign_to_models()" gets called which assigns the library to all loaded models. The problem is your model isn't recognized as loaded until "__construct()" has finished, so any libraries you load in the construct aren't assigned in the initial "_assign_libraries()" and won't be attached to your model by "_ci_assign_to_models()" because the model isn't loaded yet. Confusing I know, but it makes sense when you think it through.