From what I can see in the API, PDO provides no method in which to retrieve the original column name. Fetching the meta on it only provides the aliased name in the result. You'll need to separate the fields into a k => v hashtable pair in order to retrieve that and build your query from it.

Also, the order by you have is useless. It cannot be used in prepared statements as order by is typically a structural type, and prepared statements are data handlers. So that is treating order by as a literal string "id asc" for which it does order by that, but carries no meaning in the context of a database since 'id' will never be treated as a property and therefore defaults back to database natural ordering (which is, no guaranteed order).