mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/elem/ftp/agregaty/html/elemcms/core/connection_manager.php at line 25
<?
class ConnectionManager {
  private $connection_name;
  private $config_name;
  private $opened_transaction;


  public function __construct($params = array()) {
    $this->opened_transaction = False;
    
    if (isset($params['connection_name'])) $this->connection_name = $params['connection_name'];
    else $this->connection_name = 'default';

    if (isset($params['config_name'])) $this->config_name = $params['config_name'];
    else $this->config_name = 'default';

    $this->connect();
  }

  public function connect() {
    require_once(ROOT .'/config/database.php');

    if (!isset(MR::$connection_list[$this->connection_name]) OR !mysql_ping(MR::$connection_list[$this->connection_name]))
      {
MR::$connection_list[$this->connection_name] = mysql_connect(db_config::$conf_list[$this->config_name]['host'], db_config::$conf_list[$this->config_name]['user'], db_config::$conf_list[$this->config_name]['password'], True);
if (!mysql_ping(MR::$connection_list[$this->connection_name])) Report::error('Database connection failed', true);
  if(!mysql_select_db(db_config::$conf_list[$this->config_name]['database'], MR::$connection_list[$this->connection_name])) Report::error('Failed to select db', true);
  if(!mysql_query("SET NAMES '" .db_config::$conf_list[$this->config_name]['encoding'] ."'", MR::$connection_list[$this->connection_name])) Report::error('Failed to set names', true);
      }
    else
      {
//dunno
      }
  }

  public function disconnect() {
    if (isset(MR::$connection_list[$this->connection_name])) {
      if (mysql_ping(MR::$connection_list[$this->connection_name])) {
mysql_close(MR::$connection_list[$this->connection_name]);
MR::$connection_list[$this->connection_name] = False;
unset(MR::$connection_list[$this->connection_name]);
      }
    }
  }

  public function reconnect() {
    $this->disconnect();
    $this->connect();
  }

  public function connection_handler() {
    if (!isset(MR::$connection_list[$this->connection_name]) OR !mysql_ping(MR::$connection_list[$this->connection_name])) {
      $this->reconnect();
    }

    return MR::$connection_list[$this->connection_name];
  }

  public function transactionStart() {
    if (!$this->opened_transaction) {
      MR::query("START TRANSACTION;", $this);
      $this->opened_transaction = True;
    }
  }

  public function transactionCommit() {
    if ($this->opened_transaction) {
      MR::query("COMMIT;", $this);
      $this->opened_transaction = False;
    }
  }

  public function transactionRollback() {
    if ($this->opened_transaction) {
      MR::query("ROLLBACK;", $this);
      $this->opened_transaction = False;
    }
  }
}
?>