I can't believe you hardcoded this for MySQL instead of using PHP's excellent and versatile PDOs, and I can't believe the 10k line count. Gosh. Is "de-engineering" a suitable term here? Thumbs up for open sourcing your work, though.
Here is the suggested CI method for executing database queries: http://codeigniter.com/user_guide/database/examples.html
Nowadays, I prefer (PHP) frameworks with real autoloaders and better OOP usage (like Zend or Kohana).