-
Notifications
You must be signed in to change notification settings - Fork 0
Using Doctrine with Code Igniter Conventions
[h3]1. Download Doctrine into the application/libraries folder.[/h3]
[code] cd /path/to/ci/install/ svn co http://svn.doctrine-project.org/tags/1.1.0-RC1 system/application/libraries/doctrine [/code]
This should download the entire doctrine project with tools, vendor and docs directories. This will allow you to run the command line out of the sandbox directory. If you're running off a different release or have a different directory structure at the very least you need the following Doctrine files:
[code] system/application/libraries/doctrine/lib/Doctrine.php system/application/libraries/doctrine/lib/Doctrine/ [/code]
[h3]2. Add the config file[/h3]
Create a new file in system/application/config/ named doctrine.php. This file should contain the following:
[code] define('DOCTRINE_PATH', APPPATH . 'libraries' . DIRECTORY_SEPARATOR . 'doctrine' . DIRECTORY_SEPARATOR . 'lib'); define('DATA_FIXTURES_PATH', APPPATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures'); define('MODELS_PATH', APPPATH . 'models'); define('MIGRATIONS_PATH', APPPATH . 'MIGRATIONS'); define('SQL_PATH', APPPATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sql'); define('YAML_SCHEMA_PATH', APPPATH . DIRECTORY_SEPARATOR . 'schema');
require_once(DOCTRINE_PATH . DIRECTORY_SEPARATOR . 'Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
Doctrine_Manager::connection('mysql://root:root@127.0.0.1/test'); Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative'); [/code]
This is pieced together from the sandbox example and uses the default MAMP database settings. You'll probably need to change at least the MySQL settings but possibly the paths as well.
[h3]2. Install the custom loader[/h3]
- Original author: Derek Jones
- How to extend helpers: See User Guide
- Modified by: Thomas Stapleton (id, classes, selected country option and all option)
- Modified by: Bradley De-Lar (construct, setLayout example)