new version

This commit is contained in:
Almira Krdzic
2018-08-06 15:32:55 +02:00
parent d86f748bc6
commit 3da7e559dd
73 changed files with 256 additions and 286 deletions

View File

@@ -305,6 +305,16 @@ class GF_Query_Condition {
}
}
if ( $this->operator == self::EQ && $this->right->value == '' ) {
/**
* Empty string comparisons need a NOT EXISTS clause to grab entries that don't have the value set.
*/
$subquery = $wpdb->prepare( sprintf( "SELECT 1 FROM `%s` WHERE `meta_key` = %%s AND `entry_id` = `%s`.`id`",
GFFormsModel::get_entry_meta_table_name(), $query->_alias( null, $this->left->source ) ), $this->left->field_id );
$not_exists = new self( new GF_Query_Call( 'NOT EXISTS', array( $subquery ) ) );
return $not_exists->sql( $query );
}
$compare_condition = self::_and(
new self(
new GF_Query_Column( 'meta_key', $this->left->source, $alias ),
@@ -318,11 +328,9 @@ class GF_Query_Condition {
)
);
if ( ( in_array( $this->operator, array( self::NIN, self::NBETWEEN, self::NEQ ) ) && ! empty( $this->right ) )
|| ( $this->operator == self::EQ && $this->right->value == '' )
) {
if ( in_array( $this->operator, array( self::NIN, self::NBETWEEN, self::NEQ ) ) && ! empty( $this->right ) ) {
/**
* Empty string comparisons and negative comparisons need a NOT EXISTS clause to grab entries that
* Negative comparisons need a NOT EXISTS clause to grab entries that
* don't have the value set in the first place.
*/
$subquery = $wpdb->prepare( sprintf( "SELECT 1 FROM `%s` WHERE `meta_key` = %%s AND `entry_id` = `%s`.`id`",