使用DB2从autocomplete jquery UI返回的未定义值

I have the following code that works like a charm with mysql but when implemented using DB2, it returns value "undefined" where should be the actual value.

consult.php

require_once("connect_db.php");

$action = (isset($_GET['action'])) ? $_GET['action'] : '';
$param = (isset($_GET['parameter'])) ? $_GET['parameter'] : '';

if($action == 'autocomplete'):
    $where = (!empty($parameter)) ? "WHERE name LIKE '%{$parameter}%'" : "";
    $sql = "SELECT LOWER(name) FROM categories " . $where;

    $stmt = db2_prepare($connection, $sql);

        db2_execute($stmt);
        $data = db2_fetch_object($stmt);

    $json = json_encode($data);
    echo $json;
endif;

categories.js

$(function() {

$( "#category" ).autocomplete({
        minLength: 1,
        source: function( request, response ) {
            $.ajax({
                url: "consult.php",
                dataType: "json",
                data: {
                        action: 'autocomplete',
                    parameter: $('#category').val()
                },
                success: function(data) {
                   response(data);
                }

            });
        },

})
.autocomplete( "instance" )._renderItem = function( p, item ) {
  return $( "<p>" )
    .append( "<a><b>" + item.name + "</b></a>" )
    .appendTo( p );
};

});

There was an error in my code. I had forgotten to fetch all data as below:

    $stmt = db2_prepare($connection, $sql);

        db2_execute($stmt);

    while($row = db2_fetch_assoc($stmt)) {
            $data[] = array(
            'name' => $row['NAME']
            );
    } 

Now it is working fine