43 lines
904 B
PHP
43 lines
904 B
PHP
<?php
|
|
namespace Westdc\Db;
|
|
|
|
use Westdc\Service\AbstractServiceManager;
|
|
use Zend\Db\Adapter\Adapter;
|
|
|
|
class Db extends AbstractServiceManager
|
|
{
|
|
private $db;
|
|
|
|
function __construct(&$db = "",$param = array())
|
|
{
|
|
$configService = $this->getServiceManager()->get('Config');
|
|
$config_local = $configService->get("local.php");
|
|
|
|
if(is_array($param) && count($param)>0)
|
|
{
|
|
$this->db = new Adapter($param);
|
|
}else{
|
|
$this->db = new Adapter(array(
|
|
'driver' => $config_local->db->driver,
|
|
'hostname' => $config_local->db->hostname,
|
|
'port' => $config_local->db->port,
|
|
'database' => $config_local->db->database,
|
|
'username' => $config_local->db->username,
|
|
'password' => $config_local->db->password
|
|
));
|
|
}
|
|
|
|
$db = $this->db;
|
|
}
|
|
|
|
public function getAdapter()
|
|
{
|
|
return $this->db;
|
|
}
|
|
|
|
public function setConfig()
|
|
{
|
|
|
|
}
|
|
|
|
} |