How do you properly render the body when pulling it from the database using db_select? I have a db_select() that returns the *body_value* and *body_format* from the table field_data_body...how to I properly render that in Drupal?
I think the 'proper' way to do this is not to get the data directly from the database at all, but to use the built-in field API:

// Get an entity (node in this case).
$node = node_load(1);

// Get the view for the body field
$view = field_view_field('node', $node, 'body');


Doing it this way you won't have to bother negotiating languages or anything that, and the field will be outputted exactly as it is when it's attached to a node display.

If you do want to do it manually, though, you need to use the check_markup() function:

$text = check_markup($body_value, $body_format);


It might be worth taking note of the comments in that function, you need to be careful about accepting an arbitrary filter format without validating it:


  Note: Because filters can inject JavaScript or execute PHP code, security is vital here. When a user supplies a text format, you should validate it using filter_access() before accepting/using it. This is normally done in the validation stage of the Form API. You should for example never make a preview of content in a disallowed format.