xobb@dreamer: ~/public_html/ko3/modules/doctrine: tree -L 3
.
|-- init.php
`-- vendors
`-- doctrine <<< Doctrine, . svn externals
|-- Doctrine
`-- Doctrine.php
Kohana::modules(array(
// 'kodoc' => MODPATH.'kodoc', // Kohana documentation
// 'database' => MODPATH.'database // Database module
// 'orm' => MODPATH.'orm', // Object Relationship Mapping
'auth' => MODPATH.'auth', // Authorization & Authentication
'pagination' => MODPATH.'pagination', // Paging of results
'image' => MODPATH.'image', // Image manipulation
'doctrine' => MODPATH.'doctrine', // Doctrine ORM
'core' => MODPATH.'core', // CMS core, must be loaded after doctrine but before all CMS modules
'userguide' => MODPATH.'userguide', // User guide
// 'paypal' => MODPATH.'paypal', // PayPal integration (not complete)
// 'todoist' => MODPATH.'todoist', // Todoist integration
// 'unittest' => MODPATH.'unittest', // Unit testing
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
));
<?php defined('SYSPATH') or die('No direct script access.');
/* Doctrine integration */
require Kohana::find_file('vendors', 'doctrine/Doctrine');
/* Doctrine */
spl_autoload_register(array('Doctrine', 'autoload'));
// Doctrine
$db = Kohana::config('database')->doctrine;
// .
$manager = Doctrine_Manager::getInstance();
//
$manager->connection('mysql://'.$db['user'].':'.$db['password'].'@'.$db['host'].'/'.$db['database'], 'default_connection');
// @see www.doctrine-project.org/documentation/manual/1_1/en/configuration
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
$manager->setAttribute(Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS, array('name' => '%s_id', 'type' => 'int', 'length' => 11));
$manager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL);
$manager->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
$manager->setAttribute(Doctrine::ATTR_TBLNAME_FORMAT, $db['prefix'].'_%s');
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
// APPPATH.'models';
Doctrine::loadModels(APPPATH.'models');
Doctrine::loadModels(MODPATH.'modulename/models');
<?php
return array(
'doctrine' => array(
'user' => 'username',
'password' => 'supersecretpasword',
'host' => 'localhost',
'database' => 'fancy_site',
'prefix' => 'wtfpl',
)
);
Source: https://habr.com/ru/post/70173/
All Articles