[wp-trac] [WordPress Trac] #18574: Add class_name support to wpdb
WordPress Trac
wp-trac at lists.automattic.com
Fri Sep 2 20:03:58 UTC 2011
#18574: Add class_name support to wpdb
-------------------------+------------------------------------
Reporter: andy | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords: has-patch dev-feedback
-------------------------+------------------------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18574>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list