We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Using a search:field parameter targeting a 'legacy' field throws a MySQL error

Developer Preview

Low's avatar
Low
407 posts
7 years ago
Low's avatar Low

I used this code…

{exp:channel:entries channel="services" search:service_description="hello"}
  <div>
    {title}
  </div>
{/exp:channel:entries}

…where service_description is an existing field, so it still lives in the channel_data table. Using it in a search: parameter throws this error:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'ee4-0.exp_channel_data_field_8' doesn't exist:
SELECT t.entry_id , exp_channels.channel_id FROM exp_channel_titles AS t LEFT JOIN exp_channels ON t.channel_id = exp_channels.channel_id LEFT JOIN exp_channel_data AS wd ON wd.entry_id = t.entry_id LEFT JOIN exp_channel_data_field_8 ON exp_channel_data_field_8.entry_id = t.entry_id WHERE t.entry_id !='' AND t.site_id IN ('1') AND t.entry_date < 1509694881 AND (t.expiration_date = 0 OR t.expiration_date > 1509694881) AND t.channel_id IN (3,11) AND t.status = 'open' AND ( (wd.site_id=1 AND exp_channel_data_field_8.field_id_8 LIKE "%hello%") )ORDER BY t.sticky desc, t.entry_date desc, t.entry_id desc LIMIT 0, 100

So I’m guessing it’s not taking ‘old’ fields into account.

I’m gonna run into this issue for Low Search as well, so I’m hoping there’s gonna be a way to natively target the field’s location for similar queries.

       
Derek Jones's avatar
Derek Jones
7,561 posts
7 years ago
Derek Jones's avatar Derek Jones

Confirmed, though I was under the impression that Low Search built its own index in its own tables of the content when it’s published?

       
Low's avatar
Low
407 posts
7 years ago
Low's avatar Low

That’s only the Keywords filter. LS als has its own Field Search filter, (ie. search:field_name), so it supports additional syntax (like search:field="^foo", search:field="bar$"), it can target native fields (like search:title="lorem") and it can target Grid columns (search:grid_field:column="baz"). I’m already targeting different tables here, so I need to elaborate on that.

Same goes for the Ranges filter (queries the DB directly) and the Distance filter (same).

Preferably, I’d like to see a Field Service of some sort in EE, where you can input a field name, and get back a field ID along with the database location of its content.

I can see the legacy channel fields API is still in use, right? Or is there an alternative now?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.