Back to Table class

Method getFields

public mixed
getFields
(mixed $reload = false)
Get the columns from database table.
Parameters
  • bool $reload flag to reload cache
Returns
  • mixed An array of the field names, or false if an error occurs.
Since
  • 1.7.0
-
  • \UnexpectedValueException
Class: Table
Project: Joomla

Method getFields - Source code

/**
 * Get the columns from database table.
 *
 * @param   bool  $reload  flag to reload cache
 *
 * @return  mixed  An array of the field names, or false if an error occurs.
 *
 * @since   1.7.0
 * @throws  \UnexpectedValueException
 */
public function getFields($reload = false)
{
    $key = $this->_db->getServerType() . ':' . $this->_db->getName() . ':' . $this->_tbl;
    if (!isset(self::$tableFields[$key]) || $reload) {
        // Lookup the fields for this table only once.
        $name = $this->_tbl;
        $fields = $this->_db->getTableColumns($name, false);
        if (empty($fields)) {
            throw new \UnexpectedValueException(sprintf('No columns found for %s table', $name));
        }
        self::$tableFields[$key] = $fields;
    }
    return self::$tableFields[$key];
}