public function buildRealTableName($table, $include_dbname=true)
    {
        $table = explode(' ', $table)[0];
        $table = str_replace('#', '.', $table);
        if (($pos = strpos($table, '.')) !== false) {
            $database = substr($table, 0, $pos);
            $table = substr($table, $pos+1);
        } elseif ($prefix = $this->getTablePrefix()) {
            $database = $this->getDatabase();
            $table = strpos($table, $prefix) === 0 ? $table : $prefix . $table;
        }
        
        return $include_dbname && $database ? $database . '.' . $table : $table;
    }