ChannelField::getDataStorageTable() always returns channel_data_field_x, also for legacy fields

November 27, 2017 9:13am

Subscribe [2]
  • #1 / Nov 27, 2017 9:13am

    Low's avatar


    399 posts

    Looks like the new getDataStorageTable() method always returns channel_data_field_x, including for legacy fields that still store data in the old channel_data table.

  • #2 / Nov 27, 2017 12:58pm

    Seth Barber's avatar

    Seth Barber

    172 posts

    I’m not able to reproduce. I ran the following code (channel field #1 is legacy on my DB) and I got channel_data calling $m->getDataStorageTable(). In order for it to work the channel field must have a y in the legacy_field_data column in the channel_fields table.

    $m = ee('Model')->get('ChannelField', 1)->first();
     var_dump($m->getValues(), $m->getDataStorageTable());
  • #3 / Nov 28, 2017 2:42am

    Low's avatar


    399 posts

    Ah, it’s because I’m limiting the fields to fetch:

    $fields = ee('Model')
        ->fields('field_id', 'site_id', 'field_name', 'field_type')

    Adding legacy_field_data to the fields bit solves the issue. Not sure if it should be needed in the first place, tho.

ExpressionEngine News

#eecms, #events, #releases