Я изо всех сил, чтобы приводить в движение, чтобы подключиться к базе данных. Я создал карту классы и карты таблиц с использованием propel reverse "..."
, и создал следующую структуру:Propel - Нет соединения определяется для базы данных «по умолчанию»
propel.ini
[propel]
# A better Pluralizer
propel.builder.pluralizer.class = builder.util.StandardEnglishPluralizer
propel.xml
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
<propel>
<general>
<project>PHP-PlayArea</project>
<version>2.0.0-dev</version>
</general>
<database>
<connections>
<connection id="default">
<adapter>mysql</adapter>
<classname>Propel\Runtime\Connection\ConnectionWrapper</classname>
<dsn>mysql:host=localhost;dbname=test</dsn>
<user>me</user>
<password>blahblahblah</password>
<settings>
<charset>utf8</charset>
</settings>
</connection>
</connections>
</database>
<runtime>
<defaultConnection>default</defaultConnection>
<connection>default</connection>
</runtime>
<generator>
<defaultConnection>default</defaultConnection>
<connection>default</connection>
</generator>
</propel>
</config>
Propel. PHP
<?php namespace propel;
use Propel\Runtime\Propel;
Propel::init("../propel/propel.xml");
У меня есть следующий тест блок, который падает в течение:
// Include the main Propel script
require_once '../propel/Propel.php';
require_once '../propel/Base/Users.php';
require_once '../propel/Map/UsersTableMap.php';
require_once '../propel/Users.php';
use propel\Users;
const name = 'gareth';
class PropelTests extends \PHPUnit_Framework_TestCase {
public function testAddUser()
{
// create a user ?
$user = new Users();
// brings back an empty config
$manager = new ConfigurationManager();
//Get the array of runtime configured connections
$connections = $manager->get();
// *** fails here ***
// test connections
$con = Propel::getWriteConnection(UsersTableMap::DATABASE_NAME);
$con = Propel::getReadConnection(UsersTableMap::DATABASE_NAME);
Выходной;
C:\wamp\bin\php\php5.5.12\php.exe -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 C:\Users\gareth\AppData\Local\Temp\ide-phpunit.php --no-configuration Tests\PropelTests C:\Development\PHP-PlayArea\Tests\Propel.Tests.php
Testing started at 11:40 ...
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
<propel>
<!-- full config as above -->
</propel>
</config>
No connection defined for database "default". Did you forget to define a connection or is it wrong written?
C:\Development\PHP-PlayArea\vendor\propel\propel\src\Propel\Runtime\ServiceContainer\StandardServiceContainer.php:279
C:\Development\PHP-PlayArea\vendor\propel\propel\src\Propel\Runtime\ServiceContainer\StandardServiceContainer.php:355
C:\Development\PHP-PlayArea\propel\Base\Users.php:655
C:\Development\PHP-PlayArea\Tests\Propel.Tests.php:29
Любые идеи? Я немного озадачен ... Моя конфигурация кажется хорошей, но, очевидно, нет.
Обновление: 2015/07/06 13:01: После отладки это, похоже, это бомба, потому что ни одного менеджера соединений не был обнаружен
никогда не использовали Propel, но вы проверили путь инициализации с 'Propel :: Init ('/ путь/в/мой/файл '); '? –