Convention for database column names is underscore_notation
. Convention for class properties is camelCaseNotation
. But when I'm using SelectQuery::fields('t')
and then fetchObject()
, fetched object's properties are in underscore_notation
.
I know I can use code like:
foreach($fields as $field)
$query->addField($table_name, $field, to_camel_case($field));
That's a solution when I know fields I'm supposed to get. What if I don't? If all I want is good old SELECT * FROM {table}
? Is there a simple way to fetch object compatible with Drupal's naming convention?
I know that formally, as written, convention does not apply to objects generated dynamically and returned from PDO. I want to avoid mixed namings none the less. It feels wrong to make user input $object->camelCase
and give him $output->underscored_answer
back. Bad as in causing errors and confusion.