ajax-chat/src/AJAXChatDataBase.php

73 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2022-02-06 16:26:14 +00:00
<?php
/*
* @package AJAX_Chat
* @author Sebastian Tschan
* @copyright (c) Sebastian Tschan
* @license GNU Affero General Public License
* @link https://blueimp.net/ajax/
*/
// Class to initialize the DataBase connection:
class AJAXChatDataBase {
private $_db;
function __construct(&$dbConnectionConfig) {
switch($dbConnectionConfig['type']) {
case 'mysqli':
2022-02-06 16:36:54 +00:00
$this->_db = new AJAXChatDataBaseMySQLi($dbConnectionConfig);
2022-02-06 16:26:14 +00:00
break;
default:
2022-02-06 16:36:54 +00:00
$this->_db = new AJAXChatDataBaseMySQLi($dbConnectionConfig);
2022-02-06 16:26:14 +00:00
}
}
// 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() {
2022-02-06 17:14:13 +00:00
//return $this->_db->getName();
2022-02-06 16:26:14 +00:00
//If your database has hyphens ( - ) in it, try using this instead:
2022-02-06 17:14:13 +00:00
return '`'.$this->_db->getName().'`';
2022-02-06 16:26:14 +00:00
}
// Method to retrieve the last inserted ID:
function getLastInsertedID() {
return $this->_db->getLastInsertedID();
}
}