2013-04-13 2 views
0

symfony2에서 sqlite3을 사용하려고합니다. 이것은 응용 프로그램/설정/parameters.ymlSymfony2 및 sqlite, SQLSTATE [HY000] catch

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'정수 필드가 있습니다.

컨트롤러는 간단하다 :

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 

이 문제를 해결하는 방법에 대한 힌트 :

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'); 
    } 
} 

내가 얻을이 컨트롤러를 호출하여 요청을 실행하려고, 나는 다음과 같은 오류가있어?

감사합니다.

답변

0

sqlite 키워드 인 경우 필드 색인의 이름을 지정할 수 있습니까?

0

INDEXSQL keyword입니다.

ORM을 적절하게 이스케이프 (예 : "index"으로 작성) 할 수없는 경우 필드 이름을 다른 것으로 변경해야합니다.

+0

감사합니다. 나는 doctrine2를 사용한다. 나는 그러한 키워드가 제대로 탈출했다고 생각했다. –

관련 문제