The DB facade, in your second case, will return an object. You can then access the name of the column using the -> operator.
For example:
$result = DB::table('table')
->select('column')
->where('id', 1)
->first();
To access the column, you would then do
$result->column;
The following can also be a decent alternative:
$variable = DB::table('table')
->where('id', 1)
->value('column'); // The value is returned directly.
Now, in your first case:
$results = DB::table('nametable')
->get();
This, would return an instance of Collection. You would then need to loop over the collection to access individual rows
foreach($results as $result) {
echo $result->column; // for example
}
You could also play around with this example.