aboutsummaryrefslogtreecommitdiffstats
path: root/library/ajaxchat/chat/lib/class/AJAXChatMySQLQuery.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/AJAXChatMySQLQuery.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/AJAXChatMySQLQuery.php')
-rw-r--r--library/ajaxchat/chat/lib/class/AJAXChatMySQLQuery.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/library/ajaxchat/chat/lib/class/AJAXChatMySQLQuery.php b/library/ajaxchat/chat/lib/class/AJAXChatMySQLQuery.php
new file mode 100644
index 000000000..f2f3fd466
--- /dev/null
+++ b/library/ajaxchat/chat/lib/class/AJAXChatMySQLQuery.php
@@ -0,0 +1,89 @@
+<?php
+/*
+ * @package AJAX_Chat
+ * @author Sebastian Tschan
+ * @copyright (c) Sebastian Tschan
+ * @license Modified MIT License
+ * @link https://blueimp.net/ajax/
+ */
+
+// Class to perform SQL (MySQL) queries:
+class AJAXChatMySQLQuery {
+
+ var $_connectionID;
+ var $_sql = '';
+ var $_result = 0;
+ var $_errno = 0;
+ var $_error = '';
+
+ // Constructor:
+ function __construct($sql, $connectionID = null) {
+ $this->_sql = trim($sql);
+ $this->_connectionID = $connectionID;
+ if($this->_connectionID) {
+ $this->_result = mysql_query($this->_sql, $this->_connectionID);
+ if(!$this->_result) {
+ $this->_errno = mysql_errno($this->_connectionID);
+ $this->_error = mysql_error($this->_connectionID);
+ }
+ } else {
+ $this->_result = mysql_query($this->_sql);
+ if(!$this->_result) {
+ $this->_errno = mysql_errno();
+ $this->_error = mysql_error();
+ }
+ }
+ }
+
+ // Returns true if an error occured:
+ function error() {
+ // Returns true if the Result-ID is valid:
+ return !(bool)($this->_result);
+ }
+
+ // Returns an Error-String:
+ function getError() {
+ if($this->error()) {
+ $str = 'Query: ' .$this->_sql ."\n";
+ $str .= 'Error-Report: ' .$this->_error."\n";
+ $str .= 'Error-Code: '.$this->_errno;
+ } else {
+ $str = "No errors.";
+ }
+ return $str;
+ }
+
+ // Returns the content:
+ function fetch() {
+ if($this->error()) {
+ return null;
+ } else {
+ return mysql_fetch_assoc($this->_result);
+ }
+ }
+
+ // Returns the number of rows (SELECT or SHOW):
+ function numRows() {
+ if($this->error()) {
+ return null;
+ } else {
+ return mysql_num_rows($this->_result);
+ }
+ }
+
+ // Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE):
+ function affectedRows() {
+ if($this->error()) {
+ return null;
+ } else {
+ return mysql_affected_rows($this->_connectionID);
+ }
+ }
+
+ // Frees the memory:
+ function free() {
+ @mysql_free_result($this->_result);
+ }
+
+}
+?> \ No newline at end of file