/** * 获取当前模型对应的表名 * @param string $table * @return null|string */ public function getTable($table = '') { if ($this->_table === null) { $config = H::getConfig('db'); if ($table == '') { $class = get_called_class(); $class_arr = array_filter(preg_split("/(?=[A-Z])/", $class)); $table = implode('_', $class_arr); $table = $config['table_prefix'] . strtolower($table); } if ($this->_join) { $table .= ' as t'; } $this->_table = $table; } return $this->_table; }
public function __construct() { if ($this->_config === null) { $this->_config = H::getConfig('db'); } }