我正在尝试将 sqlite3 与 symfony2 一起使用。这是我在 app/config/parameters.yml 中的数据库配置
parameters:
database_driver: pdo_sqlite
database_host: 127.0.0.1
database_port: null
database_name: librarian
database_user: root
database_password: null
database_path: librarian
还有我的 app/config/config.yml
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
path: %kernel.root_dir%/%database_path%.db
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
我创建了一个简单的表来做一些测试。该表有一个整数自增“id”字段、一个“链接”文本字段和一个“索引”整数字段。
控制器很简单:
class testController extends Controller {
public function indexAction() {
$issue = new Issue();
$issue->setIndex(0);
$issue->setLink(array('http://example.com'));
$em = $this->getDoctrine()->getManager();
$em->persist($issue);
$em->flush();
return $this->render('TestLibrarianBundle:Test:index.html.twig');
}
}
当我尝试通过调用此控制器来执行请求时,出现以下错误:
request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "An exception occurred while executing 'INSERT INTO issue (index, link) VALUES (?, ?)':
SQLSTATE[HY000]: General error: 1 near "index": syntax error" at /.../.../vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 47
关于如何解决这个问题的任何提示?
谢谢