Tag Archives: ADAPTER

Zend Framework 2: Configure Multiple database adapters

Step 1: Consider two databases db1 and db2 with table “countries” in each database.

Step 2: Configure multiple databases in ZF2 in config/global/global.php

Step 3: Create Application/Model/CountryTable.php class to manipulate country database.

Step 4: Create another class to access database table instance:

Step 5: Create invokable under “service_manager” key in global.php… Read More »

Zend Framework 2: Configure database

Creating an Adapter Creating an adapter is done by instantiating the Zend\Db\Adapter\Adapter class.

But this is not a better way to instantiate the adapter. By default, ZF2 considers a predefined configuration key “db” (Zend\Db\Adapter\AdapterServiceFactory) so that we can define database adapter configuration in global.php with key “db”. Also, we need to create a factory… Read More »