This is what my local.php file looks like in config \ autoload \ local.php.
<?php
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'mysql:dbname=<dbname>;host=localhost',
'username' => 'root',
'password' => <your password here>,
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'aliases' => array(
'adapter' => 'Zend\Db\Adapter\Adapter',
),
),);
Now use this to create the database adapter:
$adapter = $this->getServiceLocator()->get('adapter');
Create sql status and set $ sql variable. Now do the following:
$statement = $adapter->createStatement($sql);
$result = $statement->execute();
, .