Add class_name support to wpdb
|Reported by:||andy||Owned by:|
As of PHP 5.0.0, the second parameter to mysql_fetch_object takes a class name which will be instantiated instead of stdClass. This will be handy as we upgrade core objects (see #12267 and #15458). I am using the attached patch on WordPress.com to simplify a lazy process. The effect is similar to what does with WP_User but the code is much simpler.
The attached patch is fully backward-compatible unless you have defined classes named OBJECT, OBJECT_K, ARRAY_A, or ARRAY_N.
It could be improved by supporting the third parameter to mysql_fetch_object, an array of parameters to pass to the constructor. (For instance, you might want to pass $blog_id when constructing a WP_User). Adding this parameter would be perfectly simple if get_row did not already have a third parameter, $y, which is not used in core and should be removed because it invites wasteful queries.