Drupal 7 Views 3 致命错误:无法访问受保护的属性 SelectQuery::$where
当尝试修改 Drupal 7 Views 3 过滤器中的值时,我收到此错误:
Fatal error: Cannot access protected property SelectQuery::$where in /Users/joe/Sites/sdgea/docroot/sites/all/modules/custom/sdge_video/sdge_video.module on line 275
这是导致此错误的代码:
function modulename_views_pre_execute(&$view) {
if (is_numeric($term_no)) {
// set the filter
$view->filter['tid']->value[$term_no] = $term_no;
// set the query
$view->query->where[0]['conditions'][2]['value'] = $term_no;
// set the build info
$view->build_info['query']->where->conditions[0]['field']->conditions[0]['field']->conditions[2]['value'] = $term_no;
//$view->build_info['query']->where->conditions[0]['field']->conditions[0]['field']->conditions[2]['value'] = $term_no; // <-- This line specifically is causing fatality.
}
}
可能是 D7 中某些超人对象 yada yada 的一部分。任何人对如何修改视图 3 视图 (D7) 中的过滤器的值有任何想法。
另外,要求回答为什么会访问“受保护的财产”。我是一名编码员。我不想保护任何东西!
提前致谢!
I am getting this error when attempting to modify a value in a Drupal 7 Views 3 filter:
Fatal error: Cannot access protected property SelectQuery::$where in /Users/joe/Sites/sdgea/docroot/sites/all/modules/custom/sdge_video/sdge_video.module on line 275
Here is the code that is causing this:
function modulename_views_pre_execute(&$view) {
if (is_numeric($term_no)) {
// set the filter
$view->filter['tid']->value[$term_no] = $term_no;
// set the query
$view->query->where[0]['conditions'][2]['value'] = $term_no;
// set the build info
$view->build_info['query']->where->conditions[0]['field']->conditions[0]['field']->conditions[2]['value'] = $term_no;
//$view->build_info['query']->where->conditions[0]['field']->conditions[0]['field']->conditions[2]['value'] = $term_no; // <-- This line specifically is causing fatality.
}
}
Probably part of some superhuman object yada yada in D7. Anyone have any ideas on how I can modify the value of a filter in a views 3 view (D7).
And also, request an answer of why access to a "protected property" is happening. I am a coder. I don't want anything protected!
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有点晚了,但您可以使用 hook_views_query_alter 对其进行修改,这正是出于此目的,如下所示:
It might be a bit late but you can modify it using the hook_views_query_alter, which is exactly for that purpose, like this: