blob: 8fc8d21e0a6dd99489a43f50c75e765a8b52a7a7 [file] [log] [blame]
droy974b6af2007-11-27 19:19:49 +00001<?php
droy2a1f5552014-11-03 11:04:38 -05002/*******************************************************************************
3* Copyright (c) 2007-2014 Eclipse Foundation, Intalio, Inc., IBM Corporation and others.
4* All rights reserved. This program and the accompanying materials
5* are made available under the terms of the Eclipse Public License v1.0
6* which accompanies this distribution, and is available at
7* http://www.eclipse.org/legal/epl-v10.html
8*
9* Contributors:
10* Denis Roy, Eclipse Foundation - Initial Implementation
11* Antoine Toulme, Intalio - Backend functions
12*******************************************************************************/
droy974b6af2007-11-27 19:19:49 +000013
atoulme3ac52612009-02-02 13:14:39 +000014require_once(dirname(__FILE__) . "/backend_functions.php");
droy974b6af2007-11-27 19:19:49 +000015class DBConnection {
16
droy974b6af2007-11-27 19:19:49 +000017 function connect()
18 {
19 static $dbh;
atoulme3ac52612009-02-02 13:14:39 +000020 global $addon;
21 $db_params = $addon->callHook('db_params');
droy974b6af2007-11-27 19:19:49 +000022
kitlo2c8d8a92018-04-19 13:25:09 -040023 $dbh = mysqli_connect($db_params['db_read_host'],$db_params['db_read_user'],$db_params['db_read_pass'],$db_params['db_read_name']);
atoulme3ac52612009-02-02 13:14:39 +000024 if (!$dbh) {
droy974b6af2007-11-27 19:19:49 +000025 errorLog("Failed attempt to connect to server - aborting.");
26 exitTo("/error.php?errNo=101301","error: 101301 - data server can not be found");
27 }
28
kitlo2c8d8a92018-04-19 13:25:09 -040029 /*
atoulme3ac52612009-02-02 13:14:39 +000030 $database = $db_params['db_read_name'];
droy974b6af2007-11-27 19:19:49 +000031 if (isset($database)) {
kitlo1d027092018-04-19 17:44:07 -040032 if (!mysqli_select_db($dbh, $database)) {
kitloa59efea2018-05-11 12:40:40 -040033 errorLog("Failed attempt to open database: $database - aborting \n\t" . mysqli_error($dbh));
droy974b6af2007-11-27 19:19:49 +000034 exitTo("/error.php?errNo=101303","error: 101303 - unknown database name");
35 }
droy2a1f5552014-11-03 11:04:38 -050036 }
kitlo2c8d8a92018-04-19 13:25:09 -040037 */
38 # mysqli_query($dbh, "SET character_set_results=latin1");
droy974b6af2007-11-27 19:19:49 +000039 return $dbh;
40 }
droy2a1f5552014-11-03 11:04:38 -050041
kitloa59efea2018-05-11 12:40:40 -040042 function disconnect($dbh) {
43 return mysqli_close($dbh);
droy974b6af2007-11-27 19:19:49 +000044 }
45}
46?>