I'm using custom PHP wrapper for for mysqli. The class is designed to use prepared statements if bind parameters are passed to the a fetchResultSet function otherwise, as is my understanding, it saves a call to the database and uses the query function (perhaps I'm wrong saving a call and the rest of this question can be answered by simply using prepared statements even with no parameters to bind).
Once the query has been executed a fetchResult function passes back one of two objects ResultSetObjectResult or ResultSetObjectStmt both of witch implement a ResultSetObject interface. (The ResultSetObjectStmt object wraps an stmt object while the ResultSetObjectResult wraps a result object.)
Both classes return an associative array when a row is requested either though calling fetch_assoc on a result or calling bind_result on an stmt object (basically).
What I've noticed is that if a prepared statement is executed then the data returned are properly casted to integers, real numbers and strings depending on their types in the database; but when a result is returned and fetch_assoc is called on that result then all of the data are casted as strings. I realize this is mentioned in the documentation for fetch_assoc. I'm curious if there is another function or something I can do to have mysql properly cast the results.
[EDIT] I should mention that this is only an issue because json_encode places data in quotes depending on their types.
[EDIT AGAIN] I like to know if there is anyway to properly cast the data returned from a result without resorting to guess work using functions like is_numeric or by making an additional call to the database for the schema of the table. Using prepared statements exclusively when fetching data works, but I'd really love to save that additional prepare call to the database.