The basci thought on Libraries was a way to extend Codeigniter's functionality through classes.
If you compare the blank anatomy of a Library and a Model in Codeigniter, you will see that Models extend the CI_MODEL which allows you to access Codeigniter's native resources (for Example $this->db).
Libraries do not offer that basic access and they also do not need to be extended through the CI_MODEL.
Models are made to depict and interact with data (mostly abstracted from databases such as mysql).
Take a look at the basic Library
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Library{ public function MyFunction(){ //do something... } }
...and the Model anatomy
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class User_model extends CI_Model { public function __construct(){ parent::__construct(); } public function MyFunction(){ //do something... } }
In most cases the Models are prepared to use Ressources to access databases or other functionalities. Libraries don't. You need to include or extend the Ressources manually if you need them:
//Create an CI instance $CI =& get_instance();
Libraries are tool collections and function extensions while Models are natively ideal for abstracting and interacting with data coming from databases.