我想用symfony2使用sqlite3。 這是在app /配置/ parameters.ymlSymfony2和SQLite,SQLSTATE [HY000]捕獲
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
我的數據庫配置和我的應用程序/配置/ 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'字段,一個'link'文本字段和一個'index'整數字段。
控制器很簡單:
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
如何解決這個任何提示?
感謝
好的謝謝。我使用doctrine2。我認爲很明顯這些關鍵字已經正確地逃脫了...... –