1

次のようなクエリに条件を追加しようとしています。

civicrm_contact_civicrm_relationship.id <> civicrm_contact_civicrm_relationship_1.id

しかし、2 番目のフィールドでは、drupal はそれを文字列として受け取るため、常に次のようになります。

civicrm_contact_civicrm_relationship.id <> 'civicrm_contact_civicrm_relationship_1.id'

数値で遊んでみましたが、成功しませんでした。

どうすればこれを行うことができますか?別のフックが付いている可能性がありますか?どんなヒントでも大歓迎です!

私のコード:

        $view->query->where[2]["conditions"][0]["field"] = "civicrm_contact_civicrm_relationship_1.id";
        $view->query->where[2]["conditions"][0]["operator"] = "IS NULL";
        $view->query->where[2]["conditions"][0]["value"] = "";

        $view->query->where[2]["conditions"][1]["field"] = "civicrm_contact_civicrm_relationship.id";
        $view->query->where[2]["conditions"][1]["operator"] = "IS NULL";
        $view->query->where[2]["conditions"][1]["value"] = "";

        $view->query->where[2]["conditions"][2]["field"] = "civicrm_contact_civicrm_relationship.id";
        $view->query->where[2]["conditions"][2]["value"] ="civicrm_contact_civicrm_relationship_1.id";
        $view->query->where[2]["conditions"][2]["numeric"] = "1";
        $view->query->where[2]["conditions"][2]["operator"] = "<>";

        $view->query->where[2]["type"] = "OR";
4

1 に答える 1

3

のようなものを試してください

    関数 my_hook_views_query_alter(&$view, &$query)
    {
      if ($view->name == 'my_hook') {
        $alias = $query->add_table('civicrm_contact_civicrm_relationship','civicrm_contact_civicrm_relationship_1');
        $query->add_where_expression(0,'civicrm_contact_civicrm_relationship.id <> civicrm_contact_civicrm_relationship_1.id');
        dpm($クエリ); // devel モジュールを使用してオブジェクトを admin にダンプします
      }
    }
    

于 2013-06-16T07:35:44.320 に答える