我的架構:Symfony的過濾器不工作
Poster:
actAs:
Timestampable: ~
Sluggable:
fields:[name]
columns:
id:
type: integer(4)
autoincrement: true
primary: true
name:
type: string(255)
notnull: true
filename:
type: string(255)
notnull: true
approved:
type: boolean(1)
default: false
start_date:
type: date
notnull: true
end_date:
type: date
notnull: true
user_id:
type: integer(20)
default: 1
attributes:
export: all
validate: true
relations:
User:
class: sfGuardUser
local: user_id
foreign: id
type: one
foreignType: many
foreignAlias: Posters
我有doctrine:generate-admin
生成模塊poster
。在列表視圖中,我看到的所有領域,包括start_date
和end_date
過濾器。現在,問題是,這兩個過濾器不能正常工作。例如我提供了一個範圍Start Date
和壓制filter
,在響應頁面,我看到了網頁調試工具的SQL queries
標籤但我沒有看到根據所提供的約束制約查詢的任何指示。我剛看到這一點:
SET NAMES 'UTF8'
0.00s, "doctrine" connection
SELECT COUNT(*) AS num_results FROM poster p
0.00s, "doctrine" connection
SELECT s.id AS s__id, s.first_name AS s__first_name, s.last_name AS s__last_name, s.email_address AS s__email_address, s.username AS s__username, s.algorithm AS s__algorithm, s.salt AS s__salt, s.password AS s__password, s.is_active AS s__is_active, s.is_super_admin AS s__is_super_admin, s.last_login AS s__last_login, s.created_at AS s__created_at, s.updated_at AS s__updated_at FROM sf_guard_user s
0.00s, "doctrine" connection
SELECT p.id AS p__id, p.name AS p__name, p.enabled AS p__enabled, p.layout AS p__layout, p.created_at AS p__created_at, p.updated_at AS p__updated_at, p.slug AS p__slug FROM place p
0.00s, "doctrine" connection
SELECT p.id AS p__id, p.name AS p__name, p.filename AS p__filename, p.approved AS p__approved, p.start_date AS p__start_date, p.end_date AS p__end_date, p.user_id AS p__user_id, p.created_at AS p__created_at, p.updated_at AS p__updated_at, p.slug AS p__slug FROM poster p LIMIT 10
0.00s, "doctrine" connection
SELECT s.id AS s__id, s.first_name AS s__first_name, s.last_name AS s__last_name, s.email_address AS s__email_address, s.username AS s__username, s.algorithm AS s__algorithm, s.salt AS s__salt, s.password AS s__password, s.is_active AS s__is_active, s.is_super_admin AS s__is_super_admin, s.last_login AS s__last_login, s.created_at AS s__created_at, s.updated_at AS s__updated_at FROM sf_guard_user s WHERE (s.id = '2') LIMIT 1
現在,隨着Poster
模型Timestampable,有created_at
場。我試圖給一個範圍內這一領域過濾結果,並在查詢選項卡,我現在看到
SELECT COUNT(*) AS num_results FROM poster p WHERE p.created_at >= '2011-12-15 00:00:00' AND p.created_at <= '2011-12-24 23:59:59'
的是,在symfony中的錯誤嗎?請幫忙。
UPDATE:好吧,我做了一個小調查,發現存在BasePosterFilter.class.php
沒有相應addFieldNameColumnQuery
功能。那麼,是默認的symfony行爲還是一些錯誤?
嗯,我有一個字段是一個`ForeignKey`,但我想它表現得像`Text`。我改變了`getFields`和相應的插件/ validatorSchemas。現在根據[documentation](http://www.symfony-project.org/api/1_4/sfFormFilterDoctrine)及其來源,應該調用addTextQuery,它應該添加一個`%LIKE%`查詢。什麼是實際發生的情況是要麼不加查詢或添加一個'='查詢。爲什麼會發生? – prongs 2011-12-14 13:00:55