Files
nibiru-framework.com/core/c/odbc.php
Stephan Kasdorf aff8730316 CORE UPDATE: Minor update concerning the autoloading class in the core, now it is also possible to give a loading order through the configuration
Minor update concerning the form factory classes in the core, now some javascript events are implemented as well, another update concerning functinoallity will follow soon.
             Update on the example configuration file, implementing the autoloading order of interfaces, moduels and traits.
             Update for multidatabase support, see the documentation on http://www.nibiru-framework.com
2018-08-28 11:50:22 +02:00

127 lines
2.7 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: skasdorf
* Date: 10.07.17
* Time: 13:49
*/
namespace Nibiru;
class Odbc extends Mysql implements IOdbc
{
use Messages;
protected $_readOnly = false;
private static $_instance;
protected function __construct( $section = false )
{
if($section)
{
$settings = Config::getInstance()->getConfig()[$section];
}
else
{
$settings = Config::getInstance()->getConfig()[self::SETTINGS_DATABASE];
}
$this->_setUsername($settings[self::PLACE_USERNAME]);
$this->_setPassword($settings[self::PLACE_PASSWORD]);
$this->_setDbname($settings[self::PLACE_DATABASE]);
$this->_setDiver($settings[self::PLACE_DRIVER]);
$this->_setHostname($settings[self::PLACE_HOSTNAME]);
$this->_setPort($settings[self::PLACE_PORT]);
$this->_setReadOnly($settings[self::PLACE_READONLY]);
$this->_setDsn();
$this->_setConn();
}
public static function getInstance( $section = false )
{
$className = get_called_class();
if(self::$_instance==null) self::$_instance = new $className( $section );
return self::$_instance;
}
/**
* @param string $dsn
*/
private function _setDsn( )
{
$this->_dsn = 'Driver=' . $this->getDiver() . ';Server=' . $this->getHostname() . ';Port=' . $this->getPort() . ';Database=' . $this->getDbname() . ';ReadOnly=' . $this->getReadOnly();
}
/**
* @param string $username
*/
private function _setUsername( $username )
{
$this->_username = $username;
}
/**
* @param string $password
*/
private function _setPassword( $password )
{
$this->_password = $password;
}
/**
* @param mixed $diver
*/
private function _setDiver( $diver )
{
$this->_diver = $diver;
}
/**
* @param string $hostname
*/
private function _setHostname( $hostname )
{
$this->_hostname = $hostname;
}
/**
* @param string $dbname
*/
private function _setDbname( $dbname )
{
$this->_dbname = $dbname;
}
/**
* @param string $conn
*/
private function _setConn( )
{
$this->_conn = \odbc_connect( $this->getDsn(), $this->getUsername(), $this->getPassword() );
}
/**
* @param string $port
*/
private function _setPort( $port )
{
$this->_port = $port;
}
/**
* @return boolean
*/
private function getReadOnly()
{
return $this->_readOnly;
}
/**
* @param boolean $readOnly
*/
protected function _setReadOnly( $readOnly )
{
$this->_readOnly = $readOnly;
}
}