for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Base connection class
*
* @file DbConnection.php
* PHP version 8.0+
* @author Alexander Yancharuk <alex at itvault dot info>
* @copyright © 2012-2021 Alexander Yancharuk
* @date 2013-12-31 15:44
* @license The BSD 3-Clause License
* <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
*/
namespace Veles\DataBase\Connections;
use Exception;
use Traits\DriverInterface;
use Veles\Traits\Driver;
* Class DbConnection
* Базовый класс-контейнер для хранения общих для всех соединений параметров
abstract class DbConnection implements DriverInterface
{
/** @var string */
protected $user_name;
protected $password;
protected $name;
/** @var mixed */
protected $resource;
use Driver;
* @param string $name Unique connection name
public function __construct($name)
$this->name = $name;
}
* Connection create
* Must be realized in child classes
* @return mixed
abstract public function create();
public function getResource()
if (null === $this->resource) {
$this->create();
return $this->resource;
* @param mixed $resource
public function setResource($resource)
$this->resource = $resource;
* @return string
public function getName()
return $this->name;
* @throws Exception
public function getPassword()
return $this->password;
* @param string $password
* @return $this
public function setPassword($password)
$this->password = $password;
return $this;
public function getUserName()
return $this->user_name;
* @param string $user_name
public function setUserName($user_name)
$this->user_name = $user_name;