<?php
class DBManager
{
private static  $s_conn=NULL;


  public static function getConnection()
  {
    if (DBManager::$s_conn === NULL)
    {
      /**
       * Create a new mysqli object, throw on failure.
       */

         $conn = @new mysqli(DB_HOST,DB_LOGIN,DB_PASSWORD,DB_NAME,DB_PORT);
		if (mysqli_connect_errno() !== 0)
      {
        $msg = mysqli_connect_error();
        throw new Exception($msg);
      }

      /**
       * Make sure the connection is set up for utf8
       * communications.
       */
      //$conn->query('SET NAMES \'utf-8\'');
	  $conn->query("SET NAMES 'utf8'");
      DBManager::$s_conn = $conn;
    }

    return DBManager::$s_conn;
  }
}
?>