[wp-trac] [WordPress Trac] #4826: Change to wpdb::get_col() breaks
documented behavior
WordPress Trac
wp-trac at lists.automattic.com
Mon Aug 27 19:38:15 GMT 2007
#4826: Change to wpdb::get_col() breaks documented behavior
----------------------+-----------------------------------------------------
Reporter: mdawaffe | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone: 2.3
Component: General | Version:
Severity: normal | Keywords: has-patch 2nd-opinion
----------------------+-----------------------------------------------------
[5858] [5861] Change get_col(), get_row(), and get_results() to return
null if given an empty argument.
According to the documentation, get_col() should be able to be called with
an empty argument in the following situation.
{{{
$a = get_col( "SELECT a, b FROM table" );
$b = get_col( '', 1 );
}}}
This is almost never needed since get_results() is almost always more
efficient for grabbing data from multiple columns. Very ocassionally,
this use of get_col() ''is'' more efficient and should still be supported.
Otherwise, it will be necessary to write a wrapper function around
get_results() to achieve the same thing. Since core WP does not make use
of this type of call to get_col(), any plugin that does will have to write
their own wrapper functions for the few cases where the old get_col() is
more efficient than get_results().
I cannot think of when it would be useful for get_row() or get_results()
to act in the old manner. It's only in the transformation of the data
from row-centric to column-centric that this issue occurs.
Attached is a patch that reverts get_col() and fixes a PHP warning.
--
Ticket URL: <http://trac.wordpress.org/ticket/4826>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list