3

Im creating a Zend APIgility application REST service and having a problem with my fetchAll Mapper function.

I'm connecting to an IBM DB2 database running on an i Series server (AS/400) via DB2 Connect on a Windows Application Server.

My Connection is is made in my local.php as such:

return array(
    'db' => array(
        'driver' => 'IbmDb2',
        'database' => $database,
        'username' => $user,
        'password' => $password,
        'hostname' => $host,
        'port' => $port,
        'driver_options' => array(
            'i5_naming' => DB2_I5_NAMING_ON,
            'i5_lib' => 'LIBWEB',
        ),
    ), 
);

The fetchAll() function in my Mapper class is:

public function fetchAll()
{
    $select = new Select('WBRESOURCE');
    $paginatorAdapter = new DbSelect($select, $this->adapter);
    $collection = new ResourcesCollection($paginatorAdapter);
    return $collection;
}

When I hit the DbSelect, ZF2 throws the following DB2 Connect error:

"[IBM][CLI Driver][AS] SQL0204N \"*LIBL.WBRESOURCE\" is an undefined name. SQLSTATE=42704"

Im not sure why its using *LIBL (user defined library list), since I defined the library (SCHEMA) to use as LIBWEB in my connection option.

Thanks in advance!

Rob

user1551869
  • 115
  • 4
  • From all my research and permutations, the only way I was able to get DbSelect to work was to keep, i5_naming ON and remove i5_lib. I then made sure the table I wanted to access was in the library list of the connecting user ($user). So in essence, DbSelect completely disregards i5_lib no matter the state of i5_naming option (On or Off). – user1551869 Dec 11 '14 at 15:48

1 Answers1

1

Try changing this section:

'driver_options' => array(
    'i5_naming' => DB2_I5_NAMING_ON,
    'i5_lib' => 'LIBWEB',

Change to":

'driver_options' => array(
    'i5_naming' => DB2_I5_NAMING_OFF,    <=== change
    'i5_lib' => 'LIBWEB',

By using DB2_I5_NAMING_OFF, you should get SQL naming mode. The use of DB2 i5 naming mode will result in things like reliance on a job's library list.

See PHP: db2-connect for some info on the parameter.

user2338816
  • 2,163
  • 11
  • 11
  • I did give that a whirl, with no luck. When I changed i5_naming to OFF, the ZF2 DbSelect attempted to find my table in $user.WBRESOURCE completely disregarding i5_lib. – user1551869 Dec 11 '14 at 15:45
  • I just realized that your original name is shown as `"*LIBL.WBRESOURCE"`. There should not be a "." included as the delimiter in the middle of the name when DB2_I5_NAMING_ON is set. The delimiter should be a "/". That makes me wonder if Zend Support should be contacted to see if there's a known bug-fix. – user2338816 Dec 12 '14 at 01:08