到目前为止,我正在阅读学说教程并喜欢它,但是我被困在删除/重新生成数据库模式的点上。
这是我正在使用的代码(几乎直接来自教程)
require_once(dirname(__FILE__) . '/lib/vendor/doctrine/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
$dsn = 'mysql:dbname=test;host=127.0.0.1';
$user = 'root';
$password = 'test';
$dbh = new PDO($dsn, $user, $password);
$conn = Doctrine_Manager::connection($dbh);
$conn->setOption('username', $user);
$conn->setOption('password', $password);
Doctrine::loadModels('models');
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'
谁能告诉我用于 DSN 的正确语法,给出的示例有点令人困惑。
我通过 XAMPP 在 localhost 上运行。
任何建议表示赞赏。
谢谢。