Use the Database Library separately from CodeIgniter 2.
Copy the first part of the code in sample.php to the top of your script. Note that your should change all $this->db to $db.
You can read the Tutorial in Chinese.
Same as the CodeIgniter License Agreement. Included in the license.txt.
https://github.com/gisanfu/codeigniter2-activerecord-standalone.git
http://hasin.me/2007/06/13/using-activerecord-library-separately-from-codeigniter/