wordpress 的 taxonomy.php 源码中,有
function find_compatible_table_alias( $clause, $parent_query )
参数说明:
@param array $clause Query clause.
@param array $parent_query Parent query of $clause.
@return string|false Table alias if found, otherwise false
困惑我好久的问题是:何谓 parent query ?请教达人。
附:源码
protected function find_compatible_table_alias( $clause, $parent_query ) {
1164 $alias = false;
1165
1166 // Sanity check. Only IN queries use the JOIN syntax .
1167 if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) {
1168 return $alias;
1169 }
1170
1171 // Since we're only checking IN queries, we're only concerned with OR relations.
1172 if ( ! isset( $parent_query['relation'] ) || 'OR' !== $parent_query['relation'] ) {
1173 return $alias;
1174 }
1175
1176 $compatible_operators = array( 'IN' );
1177
1178 foreach ( $parent_query as $sibling ) {
1179 if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) {
1180 continue;
1181 }
1182
1183 if ( empty( $sibling['alias'] ) || empty( $sibling['operator'] ) ) {
1184 continue;
1185 }
1186
1187 // The sibling must both have compatible operator to share its alias.
1188 if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) {
1189 $alias = $sibling['alias'];
1190 break;
1191 }
1192 }
1193
1194 return $alias;
1195 }
何谓 first_order_clause?
Determine whether a clause is first-order
protected static function is_first_order_clause( $query ) {
return is_array( $query ) && ( empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ) );
}
请教达人。
function find_compatible_table_alias( $clause, $parent_query )
参数说明:
@param array $clause Query clause.
@param array $parent_query Parent query of $clause.
@return string|false Table alias if found, otherwise false
困惑我好久的问题是:何谓 parent query ?请教达人。
附:源码
protected function find_compatible_table_alias( $clause, $parent_query ) {
1164 $alias = false;
1165
1166 // Sanity check. Only IN queries use the JOIN syntax .
1167 if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) {
1168 return $alias;
1169 }
1170
1171 // Since we're only checking IN queries, we're only concerned with OR relations.
1172 if ( ! isset( $parent_query['relation'] ) || 'OR' !== $parent_query['relation'] ) {
1173 return $alias;
1174 }
1175
1176 $compatible_operators = array( 'IN' );
1177
1178 foreach ( $parent_query as $sibling ) {
1179 if ( ! is_array( $sibling ) || ! $this->is_first_order_clause( $sibling ) ) {
1180 continue;
1181 }
1182
1183 if ( empty( $sibling['alias'] ) || empty( $sibling['operator'] ) ) {
1184 continue;
1185 }
1186
1187 // The sibling must both have compatible operator to share its alias.
1188 if ( in_array( strtoupper( $sibling['operator'] ), $compatible_operators ) ) {
1189 $alias = $sibling['alias'];
1190 break;
1191 }
1192 }
1193
1194 return $alias;
1195 }
何谓 first_order_clause?
Determine whether a clause is first-order
protected static function is_first_order_clause( $query ) {
return is_array( $query ) && ( empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ) );
}
请教达人。
解决方案 »
- 请教关于$_POST值时有时无的问题
- 请问php中 exit($status)表示什么
- 这种网站是用什么语言开发的啊?
- PHP 调用外部SMTP发邮件的回执问题
- CSS FF兼容
- 北京联众诚聘php、java开发工程师!
- 大家好,用xampp安装的php环境安装项目后局域网访问不了
- 如何把键值相同的合并,并且把键名的值相加,然后按照键名的值的大小形成一个新的数组,请高人指点。
- 关于php连接oracle的问题
- session 安全吗?
- 求大神指点,有关 file_get_contents()
- PHPCMS提交内容出现Fatal error:Call to undefined function...
$terms = $wpdb->get_col( "
SELECT $wpdb->term_taxonomy.$resulting_field
FROM $wpdb->term_taxonomy
INNER JOIN $wpdb->terms USING (term_id)
WHERE taxonomy = '{$query['taxonomy']}'
AND $wpdb->terms.{$query['field']} IN ($terms)
在 transform_query( &$query, $resulting_field ) 中,有上面的代码。能否以此为例讲一下?
关于函数 find_compatible_table_alias( $clause, $parent_query ) 有这样的
说明,哪位达人解释一下?谢谢
Identify an existing table alias that is compatible with the current query clause. *
* We avoid unnecessary table joins by allowing each clause to look for
* an existing table alias that is compatible with the query that it
* needs to perform.
*
* An existing alias is compatible if (a) it is a sibling of `$clause`
* (ie, it's under the scope of the same relation), and (b) the combination
* of operator and relation between the clauses allows for a shared table
* join. In the case of WP_Tax_Query, this only applies to 'IN'
* clauses that are connected by the relation 'OR'.
父查询子句find_compatible_table_alias 查找兼容表别名对于具体解释,你就不能找个中文的教程看看吗?
在wordpress 里,parent query 到底是哪些?有些迷糊