Skip to:
Content
Pages
Categories
Search
Top
Bottom

$bbdb->get_results report warning when there is no record in db, is it a bug?

  • @hankjin

    Member

    when I use $bbdb->get_results($sql, ARRAY_K); it reports warning when there is no records in database.

    then I checked the code bb-includes/backpress/class.bpdb.php:

    936 $key = $this->col_info[0]->name;

    937 foreach ( $this->last_result as $row ) {

    938 if ( !isset( $new_array[ $row->$key ] ) ) {

    939 $new_array[ $row->$key ] = $row;

    940 }

    941 }

    942 if ( $output == ARRAY_K ) {

    943 return array_map( ‘get_object_vars’, $new_array );

    944 }

    945 return $new_array;

    It seems when the query result is empty, $new_array is not initialized, so warning happens in Line 943

    so I add a line $new_array=array(); before the foreach statement of Line 937, then everything goes well.

    The code now looks like this:

    936 $key = $this->col_info[0]->name;

    937 $new_array=array();

    938 foreach ( $this->last_result as $row ) {

    939 if ( !isset( $new_array[ $row->$key ] ) ) {

    940 $new_array[ $row->$key ] = $row;

    941 }

    942 }

    943 if ( $output == ARRAY_K ) {

    944 return array_map( ‘get_object_vars’, $new_array );

    945 }

    946 return $new_array;

    so I think maybe this is a bug.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar