PHP code example of radnan / rdn-database

1. Go to this page and download the library: Download radnan/rdn-database library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radnan / rdn-database example snippets



   return array(
       'modules' => array(
           'RdnDatabase',
           // ...
       ),
   );
   ~~~

## How to use

Simply configure your database adapters with the `RdnDatabase\Adapter\AdapterManager` service locator using the `rdn_db_adapters` configuration option. Adapters are instances of the `Zend\Db\Adapter\Adapter` class.

~~~php


return array(
	'rdn_db_adapters' => array(
		'invokables' => array(),
		'factories' => array(),
	),
);
~~~

You can use the **adapters** key to dynamically create adapters using simple configuration:

~~~php


return array(
	'rdn_db_adapters' => array(
		'adapters' => array(
			'default' => array(
				'driver'   => 'pdo_mysql',
				'hostname' => null,
				'port'     => null,
				'username' => null,
				'password' => null,
				'database' => null,
			),
		),
	),
);
~~~

The configuration options are used to create a `Zend\Db\Adapter\Adapter` object.

### Controller Plugin

The module comes with the `database()` controller plugin that you can use to fetch database adapters from within a controller:

~~~php
class FooController
{
	public function indexAction()
	{
		/** @var \Zend\Db\Adapter\Adapter $adapter */
		$adapter = $this->database('default');
	}