Thread

ChannelField::getDataTable() always returns 'channel_data'

November 10, 2017 4:17am

Subscribe [3]
  • #1 / Nov 10, 2017 4:17am

    Low's avatar

    Low

    399 posts

    I’m trying to determine where a given channel field is stored. Thought I could use the getDataTable() on the ChannelField model, but that always returns 'channel_data', even for Fluid fields, which will never be in that table.

  • #2 / Nov 15, 2017 5:21am

    Low's avatar

    Low

    399 posts

    I’m guessing it will be tricky to determine what to return when a given field can be stand-alone or part of a Fluid field… But, ideally, this method should return the table name where the content is stored. Is this going to be the case? It will be very useful for building custom queries that aren’t currently possible using Models (like calculating Haversine distance using 2 fields as lat and long values).

  • #3 / Nov 15, 2017 11:42am

    Seth Barber's avatar

    Seth Barber

    168 posts

    Low,

    I’m adding the following method to FieldModel in the next release:

    public function getDataStorageTable()
    {
     if ( ! $this->hasProperty($this->getColumnPrefix().'legacy_field_data')
      || $this->getProperty($this->getColumnPrefix().'legacy_field_data') == TRUE)
     {
      return $this->getDataTable();
     }
     
     return $this->getTableName();
    }

ExpressionEngine News

#eecms, #events, #releases