/**
* 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];
}