From 724ad4505628d493b43b4f585512d67dc0b4ee76 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 18 Jan 2014 23:49:39 -0800 Subject: 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. --- .../chat/lib/class/AJAXChatMySQLiQuery.php | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 library/ajaxchat/chat/lib/class/AJAXChatMySQLiQuery.php (limited to 'library/ajaxchat/chat/lib/class/AJAXChatMySQLiQuery.php') diff --git a/library/ajaxchat/chat/lib/class/AJAXChatMySQLiQuery.php b/library/ajaxchat/chat/lib/class/AJAXChatMySQLiQuery.php new file mode 100644 index 000000000..f81afd886 --- /dev/null +++ b/library/ajaxchat/chat/lib/class/AJAXChatMySQLiQuery.php @@ -0,0 +1,81 @@ +_sql = trim($sql); + $this->_connectionID = $connectionID; + $this->_result = $this->_connectionID->query($this->_sql); + if(!$this->_result) { + $this->_errno = $this->_connectionID->errno; + $this->_error = $this->_connectionID->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 $this->_result->fetch_assoc(); + } + } + + // Returns the number of rows (SELECT or SHOW): + function numRows() { + if($this->error()) { + return null; + } else { + return $this->_result->num_rows; + } + } + + // Returns the number of affected rows (INSERT, UPDATE, REPLACE or DELETE): + function affectedRows() { + if($this->error()) { + return null; + } else { + return $this->_connectionID->affected_rows; + } + } + + // Frees the memory: + function free() { + $this->_result->free(); + } + +} +?> \ No newline at end of file -- cgit v1.2.3