blob: 2143c5aa0312a8a92b1b008ac4fe6d8b2bffb444 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license Modified MIT License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the DataBase connection:
class AJAXChatDataBase {
var $_db;
function __construct(&$dbConnectionConfig) {
switch($dbConnectionConfig['type']) {
case 'mysqli':
$this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig);
break;
case 'mysql':
$this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig);
break;
default:
// Use MySQLi if available, else MySQL (and check the type of a given database connection object):
if(function_exists('mysqli_connect') && (!$dbConnectionConfig['link'] || is_object($dbConnectionConfig['link']))) {
$this->_db = new AJAXChatDatabaseMySQLi($dbConnectionConfig);
} else {
$this->_db = new AJAXChatDatabaseMySQL($dbConnectionConfig);
}
}
}
// Method to connect to the DataBase server:
function connect(&$dbConnectionConfig) {
return $this->_db->connect($dbConnectionConfig);
}
// Method to select the DataBase:
function select($dbName) {
return $this->_db->select($dbName);
}
// Method to determine if an error has occured:
function error() {
return $this->_db->error();
}
// Method to return the error report:
function getError() {
return $this->_db->getError();
}
// Method to return the connection identifier:
function &getConnectionID() {
return $this->_db->getConnectionID();
}
// Method to prevent SQL injections:
function makeSafe($value) {
return $this->_db->makeSafe($value);
}
// Method to perform SQL queries:
function sqlQuery($sql) {
return $this->_db->sqlQuery($sql);
}
// Method to retrieve the current DataBase name:
function getName() {
return $this->_db->getName();
//If your database has hyphens ( - ) in it, try using this instead:
//return '`'.$this->_db->getName().'`';
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return $this->_db->getLastInsertedID();
}
}
?>
|