对象关系列表字段的标准

时间:2015-03-11 17:00:04

标签: ezpublish

使用eZ Publish 2014.11,我想在objectrelationlist字段中过滤搜索结果。

我使用此代码(我删除了与objectrelatiolist字段无关的所有部分):

        $query->query = new Criterion\LogicalAnd(
        array(
            // ...
            new Criterion\Field(  'myField', Criterion\Operator::EQ, my_value ),
            // ...
        )
    );

根据分析器,生成的查询看起来像这样(我删除了与objectrelatiolist字段无关的所有部分):

SELECT 
-- ...
      AND `ezcontentobject`.`id` IN (
        SELECT 
          `contentobject_id` 
        FROM 
          `ezcontentobject_attribute` 
        WHERE 
          (
            -- ...
            AND (
              `contentclassattribute_id` IN ('342') 
              AND `sort_key_string` = my_value
            )
          )
      ) 
-- ... 

数据库中的表示sort_key_string对于字段行为空(尽管data_text字段中显示现有关系):

*************************** 385. row ***************************
   attribute_original_id: 0
contentclassattribute_id: 342
        contentobject_id: 137
              data_float: 0
                data_int: NULL
               data_text: <?xml version="1.0" encoding="utf-8"?>
<related-objects><relation-list><relation-item priority="1" contentobject-id="67" contentobject-version="1" node-id="69" parent-node-id="2" contentclass-id="43" contentclass-identifier="theme" contentobject-remote-id="00162a519495cd3b956192ea30b68761"/><relation-item priority="2" contentobject-id="68" contentobject-version="1" node-id="70" parent-node-id="2" contentclass-id="43" contentclass-identifier="theme" contentobject-remote-id="853215e40ca057a787a8cea9cdd5ddce"/></relation-list></related-objects>

        data_type_string: ezobjectrelationlist
                      id: 614
           language_code: fre-FR
             language_id: 2
            sort_key_int: 0
         sort_key_string: 
                 version: 1

所以我的问题是:有没有办法在objectrelationlist上使用标准搜索内容?

1 个答案:

答案 0 :(得分:5)

我应该使用fieldRelation这样的标准:

new Criterion\FieldRelation(  'myField', Criterion\Operator::IN, array(my_value) ),