Я работал над введением по ссылке ниже и смог выполнить предыдущие шаги, но когда дело доходит до запуска файла generate.php, я получаю сообщение об ошибке в dsn.Есть ли пропущенные шаги, которые были опущены при изменении DSN?http://www.doctrine -project.org / projects / orm / 1.2 / документы / руководство / введение в модели / ru # введение в модели
-----------------------------------
error output
-----------------------------------
Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with message 'You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality' in /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Connection.php:1460
Stack trace:
#0 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Manager.php(707): Doctrine_Connection->dropDatabase()
#1 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Core.php(972): Doctrine_Manager->dropDatabases(Array)
#2 /Users/sone/sources/doctrine1.2/doctrine_test/generate.php(8): Doctrine_Core::dropDatabases()
#3 {main}
thrown in /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Connection.php on line 1460
-----------------------------------
FatalОшибка с Doctrine при использовании generate.php
Я видел подобную проблему (ссылка выше) с файлом generate.php здесь, но предлагаемое решение и ошибка немного отличаются и не работают в моем случае,Изменение строки dsn на $ conn = Doctrine_Manager :: connection ('mysql: // sonint99: C2sHF9Zxq3ULXCTV@127.0.0.1/doctrine');тоже не работает.Теперь я получаю эту ошибку.
si2: doctrine_test sone $ php generate.php
Fatal error: Uncaught exception 'Doctrine_Manager_Exception' with message 'Unknown connection: doctrine' in /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Manager.php:512
Stack trace:
#0 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Manager.php(554): Doctrine_Manager->getConnection('doctrine')
#1 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Export.php(1107): Doctrine_Manager->getConnectionForComponent('Test')
#2 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Export.php(1205): Doctrine_Export->exportSortedClassesSql(Array)
#3 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Export.php(1100): Doctrine_Export->exportClasses(Array)
#4 /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Core.php(894): Doctrine_Export->exportSchema('models')
#5 /Users/sone/sources/doctrine1.2/doctrine_test/generate.php(11): Doctrine_Core::createTablesFromModels('models')
#6 {main}
in /Users/sone/sources/doctrine1.2/doctrine_test/lib/vendor/doctrine/Doctrine/Manager.php on line 512
мой загрузочный ремень
<?php
// bootstrap.php
/**
* Bootstrap Doctrine.php, register autoloader specify
* configuration attributes and load models.
*/
require_once(dirname(__FILE__) . '/lib/vendor/doctrine/Doctrine.php');
// ...
spl_autoload_register(array('Doctrine', 'autoload'));
// ...
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true);
// Setting up DB connection
$dsn = 'mysql:dbname=doctrine;host=127.0.0.1';
$user = 'sonint99';
$password = 'C2sHF9Zxq3ULXCTV';
$dbh = new PDO($dsn, $user, $password);
$conn = Doctrine_Manager::connection($dbh,'doctrine');
Doctrine_Core::loadModels('models');
//$conn = Doctrine_Manager::connection('mysql://sonint99:C2sHF9Zxq3ULXCTV@127.0.0.1/doctrine');
generate.php
<?php
// generate.php
require_once('bootstrap.php');
Doctrine_Core::dropDatabases();
Doctrine_Core::createDatabases();
Doctrine_Core::generateModelsFromYaml('schema.yml', 'models');
Doctrine_Core::createTablesFromModels('models');
schema.yml
Test:
connection: doctrine
tableName: test
columns:
id:
type: integer(8)
autoincrement: true
primary: true
name:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
User:
connection: doctrine
tableName: user
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
first_name:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
last_name:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
username:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
password:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
type:
type: string(255)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
is_active:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '1'
notnull: false
autoincrement: false
is_super_admin:
type: integer(1)
fixed: false
unsigned: false
primary: false
default: '0'
notnull: false
autoincrement: false
created_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
updated_at:
type: timestamp(25)
fixed: false
unsigned: false
primary: false
default: '0000-00-00 00:00:00'
notnull: true
autoincrement: false