2012-05-30 128 views
0

最近,我一直在探索Symfony的sfDoctrineGenerator作为我的后端接口。问题是这样的:sfDoctrineGenerator删除不起作用

我正在使用sfDoctrineGuardPlugin进行用户管理。 sfGuardUser模块使用sfDoctrineGenerator。所有需要的功能(删除,编辑,添加)正在工作。到现在为止还挺好。

然后我使用这个link作为参考创建了一个新模块。添加和编辑功能现在可以工作,但我无法删除(批量和单个删除)工作。我试图在批处理操作下明确添加它,但它仍然不起作用。它说它已经删除,显示一个Flash消息成功,但没有元素被删除。有人可以指出问题可能源于何处的正确方向吗?

这里是我的generator.yml

generator: 
    class: sfDoctrineGenerator 
    param: 
    model_class:   News 
    theme:     admin 
    non_verbose_templates: true 
    with_show:    false 
    singular:    ~ 
    plural:    ~ 
    route_prefix:   news 
    with_doctrine_route: true 
    actions_base_class: sfActions 

    config: 
     actions: ~ 

     fields: 
     news: {label: Announcement} 
     created_at: {label: Date Published} 
     updated_at: {label: Date Updated} 
     user_id: {label: Author} 
     user_name: {label: Author} 

     list:  
     title:   Announcements List 
     display:  [=title, created_at, updated_at, user_name] 
     sort:   [created_at, desc] 
     max_per_page: 10 
     batch_actions: 
      _delete: ~ 

     filter: 
     display: [title, user_id] 

     form: 
     class: NewsForm 

     edit:  
     title: Editing Announcement "%%title%%" 

     new:  
     title: New Announcement 

的副本如果你需要从我其他的东西,请不要犹豫发表评论。任何帮助都感激不尽。提前致谢。

UPDATE:

这里是在浏览器中查看请求报头:

Request URL:http://localhost:8080/inventory_dev.php/news 
Request Method:GET 
Status Code:200 OK 
Request Headersview source 
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 
Accept-Encoding:gzip,deflate,sdch 
Accept-Language:en-US,en;q=0.8 
Cache-Control:max-age=0 
Connection:keep-alive 
Cookie:ja_purity_tpl=ja_purity; fontSize=100; __atuvc=312|19; JSESSIONID=9DDD204812F0C53A8B3D33B89BF7A7C8; matciis=ha6l8ci8h3i2bp696e4h33vig2; symfony=ld2qept3j5cddjsb16qie098u3 
Host:localhost:8080 
Referer:http://localhost:8080/inventory_dev.php/news 
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5 
Response Headersview source 
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0 
Connection:Keep-Alive 
Content-Type:text/html; charset=utf-8 
Date:Wed, 30 May 2012 08:30:02 GMT 
Expires:Thu, 19 Nov 1981 08:52:00 GMT 
Keep-Alive:timeout=5, max=99 
Pragma:no-cache 
Server:Apache/2.2.21 (Win32) PHP/5.3.8 
Transfer-Encoding:chunked 
X-Powered-By:PHP/5.3.8 
+0

您是否跟踪可能会删除该行的sql查询? – j0k

+0

我很抱歉。你有什么建议我应该怎么做?我试图通过删除按钮后通过fronend_dev.php控制器访问该网站,但所有查询都是SELECT的。 – nmenego

+0

我要求你检查[查询来自MySQL](http://www.electrictoolbox.com/logging-queries-with-mysql/)(如果你使用它),当你按下时查看'DELETE'查询在后端的删除链接。因此,您将能够在phpMyAdmin中测试查询(例如)以查看SQL错误消息。 – j0k

回答

0

这是D'OH时刻在生活中的一个。

的问题是,在我的schema.yml,我规定:

actAs: { Timestampable: ~ , SoftDelete: ~ } 

这意味着,当我删除元素,它只会增加的时间戳它,而不是物理删除。我从配置中删除了SoftDelete,问题得到解决。

也许在sfDoctrineGenerator中应该有一个功能来支持SoftDelete?