Talk:Requests for comment/SQL framework

Other frameworks
I'd like to discuss other frameworks for SQL abstraction like the widely-used Doctrine. -- ☠ MarkAHershberger ☢ (talk) ☣ 16:28, 4 January 2014 (UTC)
 * Doctrine's API looks very similar to Wikia's. The main differences I saw are:
 * Doctrine uses lowercase method names while Wikia uses uppercase . I like lowercase better.
 * Wikia uses underscores in  and   to prevent clashing with PHP keywords, Doctrine avoids this. I think the underscores are very confusing, you have to remember which ones have an underscore and which ones don't.
 * Doctrine uses  and   instead of , not only to avoid the underscore problem but also to allow appending to the WHERE and HAVING clauses separately
 * Doctrine does not have  or any equivalent functionality :(
 * Doctrine uses PDO-style placeholders like  which you then have to bind a value to. I don't like this because:
 * Using unnamed placeholders leaves you with a rather meaningless list of values at the end
 * Using named placeholders fixes that, but makes the query quite verbose
 * The disconnect between the query and the values potentially makes harder
 * Doctrine explicitly does not paper over differences between SQL implementations in any way. MW's existing SQL framework explicitly does abstract differences between SQL implementations, table prefixes, etc. etc. I think that's an important feature and one we need to retain
 * --Catrope (talk) 10:13, 7 January 2014 (UTC)

Extensibility
One major advantage of the associative array style we use now is that you can take an associative array that describes a query, hand it to some other piece of code (e.g. an extension hook or a method implemented by a subclass), and get back a slightly modified version of the query. An array-based format makes this easy because you can just do  or   or whatever.

With the chained style used by both Wikia's SQL framework and Doctrine, it's possible to implement this as well. But you don't quite get it for free, you have to design around it. I think any new way for handling SQL in MW should continue to support query modification like this. --Catrope (talk) 09:14, 7 January 2014 (UTC)