- πΊπΈUnited States smustgrave
Wonder if this is still a valid task 13 years later?
The following database fetch methods require numeric indices:
With dynamic queries, per Crell, there is "no guarantee" as to the order of the fields in the returned result. In particular, expressions are always added after fields, which can easily result in unexpected results being returned.
Consider the following example: One module defines a query with one field and one expression. The module expects the field to be index 0 and the expression to be index 1, and so uses:
$query->execute()->fetchAllKeyed(0, 1); // The default indices
However, another module alters the query, adding a field. The result? Suddenly, the first module is fetching an entirely different field!
It would be better for these methods to accept table aliases, like fetchAllAssoc() does. We could include a is_numeric()
check for backwards compatibility and to allow the convenience of numeric indices for static queries, which are not affected by this issue.
I've updated the handbook with a warning about these methods at http://drupal.org/node/310075#executing_the_query. If this is fixed, that documentation can be removed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Wonder if this is still a valid task 13 years later?