Try this as a library alternative:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Doctrine ORM factory for Modular Extensions - PHP5
*
* Install this file as application/libraries/Doctrine_orm.php
*
* @version: 0.2
* $copyright Copyright (c) Wiredesignz 2009-11-29
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require_once APPPATH.'vendor/Doctrine/lib/Doctrine.php';
/* this allows Doctrine to load classes as needed */
spl_autoload_register(array('Doctrine', 'autoload'));
class Doctrine_ORM {
public $manager;
function __construct() {
include APPPATH.'/config/database.php';
/* create the DSN connection for Doctrine */
foreach ($db as $connection => $values) {
$dsn = "{$db[$connection]['dbdriver']}://{$db[$connection]['username']}:{$db[$connection]['password']}@{$db[$connection]['hostname']}/{$db[$connection]['database']}";
Doctrine_Manager::connection($dsn, $connection);
}
$this->manager = Doctrine_Manager::getInstance();
}
static function Factory($model) {
list($path, $_model) = Modules::find($model, NULL, 'models/');
if ($path == FALSE) {
$path = APPPATH.'models/';
}
Modules::load_file($_model, $path);
$class = ucfirst($_model);
return new $class();
}
}
Version 0.2 : Only started this a short time ago so there may be issues.
application/config/autoload.php
$autoload['libraries'] = array('doctrine_orm');
Usage:
$dao = Doctrine_ORM::Factory('module/model');
Note: The Doctrine libraries should be located in a new application/vendor/Doctrine directory.