aboutsummaryrefslogtreecommitdiffstats
path: root/library/ajaxchat/chat/lib/class/AJAXChatDataBase.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-18 23:49:39 -0800
committerfriendica <info@friendica.com>2014-01-18 23:49:39 -0800
commit724ad4505628d493b43b4f585512d67dc0b4ee76 (patch)
tree4fb920a79e3dff961a6301ec56ec9f40e91f6af3 /library/ajaxchat/chat/lib/class/AJAXChatDataBase.php
parent3f7032e542e3c451507fc9266ab3536155c8190f (diff)
downloadvolse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.tar.gz
volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.tar.bz2
volse-hubzilla-724ad4505628d493b43b4f585512d67dc0b4ee76.zip
add ajaxchat library - needs a lot of integration work to handle decentralisation (e.g. chatroom@website) and zotid w/permissions (e.g. ACL controlled chatrooms); we can also rip out a lot of stuff we don't need.
Diffstat (limited to 'library/ajaxchat/chat/lib/class/AJAXChatDataBase.php')
-rw-r--r--library/ajaxchat/chat/lib/class/AJAXChatDataBase.php81
1 files changed, 81 insertions, 0 deletions
diff --git a/library/ajaxchat/chat/lib/class/AJAXChatDataBase.php b/library/ajaxchat/chat/lib/class/AJAXChatDataBase.php
new file mode 100644
index 000000000..2143c5aa0
--- /dev/null
+++ b/library/ajaxchat/chat/lib/class/AJAXChatDataBase.php
@@ -0,0 +1,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();
+ }
+
+}
+?> \ No newline at end of file