0

In a plugin, I have this as part of the SQL's WHERE clause:

$where_sql = "`store_table`.`channel_id` = {$this->channel_ids->stores}
                AND `regions`.{$this->field_column_names->region->region_name} IN ({$regions})
                AND `regions`.{$this->field_column_names->region->region_name} != ''
                AND `address_types`.{$this->field_column_names->address_type->address_type} = 'Physical'
                AND `store_address_data_grid_table`.{$this->grid_column_names->store_address_data->store_address_latitude} != ''
                AND `store_address_data_grid_table`.{$this->grid_column_names->store_address_data->store_address_longitude} != ''
        ";

I need this query to respect that entry's status (e.g. status = Open). How do I add that to this query?

EDIT 1:

It looks like the status value is saved in exp_channel_titles and actually stores the value values ("open", "closed") instead of an id. Anyway, I'm not sure how I'd add this to the WHERE clause.

1
  • Can you post the full query, this appears to just be the where clause.
    – foamcow
    Nov 6 '14 at 9:27
1

You would need to perform a JOIN on the entry id column in the two tables then set a WHERE clause for titles table. If you're unfamiliar with JOINs then if you can post the full query we may be able to work it out for you.

2
  • I can do a JOIN. I'm just not sure which table to be JOINing. Where do I get the status of a channel entry? Nov 9 '14 at 21:46
  • The entry status is in the exp_channel_titles table.
    – foamcow
    Nov 10 '14 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.