From 4e6b68a709c1169da61e2c2cb4c7dd82d0403f6d Mon Sep 17 00:00:00 2001
From: Cameron <e107inc@gmail.com>
Date: Mon, 11 Feb 2019 16:19:07 -0800
Subject: [PATCH] new methods added to PDO class.

---
 e107_handlers/e_db_interface.php    | 30 ++++++++++++++++++++
 e107_handlers/e_db_legacy_trait.php |  2 +-
 e107_handlers/e_db_pdo_class.php    | 43 +++++++++++++++++++++++++----
 3 files changed, 68 insertions(+), 7 deletions(-)

diff --git a/e107_handlers/e_db_interface.php b/e107_handlers/e_db_interface.php
index 877d8a7d4..cef4b249f 100644
--- a/e107_handlers/e_db_interface.php
+++ b/e107_handlers/e_db_interface.php
@@ -369,7 +369,37 @@
 		public function columnCount();
 
 
+		/**
+		 * Set the current database language
+		 * @param string $lang English, French etc.
+		 * @return null
+		 */
+		public function setLanguage($lang);
 
 
 
+		/**
+		 * Get the current database language
+		 * @return string $lang English, French etc.
+		 */
+		public function getLanguage();
+
+
+
+		/**
+		 * Drop/delete table and all it's data
+		 * @param string $table name without the prefix
+		 * @return bool|int
+		 */
+		public function dropTable($table);
+
+
+
+
+		/**
+		 * Returns the last database query used.
+		 * @return string
+		 */
+		function getLastQuery();
+
 }
\ No newline at end of file
diff --git a/e107_handlers/e_db_legacy_trait.php b/e107_handlers/e_db_legacy_trait.php
index 3696803bf..139f5ca25 100644
--- a/e107_handlers/e_db_legacy_trait.php
+++ b/e107_handlers/e_db_legacy_trait.php
@@ -99,7 +99,7 @@
 
 		function db_IsLang($table, $multiple=false)
 		{
-			$this->hasLanguage($table, $multiple);
+			return $this->hasLanguage($table, $multiple);
 		}
 
 
diff --git a/e107_handlers/e_db_pdo_class.php b/e107_handlers/e_db_pdo_class.php
index 0f9d2b849..9c6f17dc3 100644
--- a/e107_handlers/e_db_pdo_class.php
+++ b/e107_handlers/e_db_pdo_class.php
@@ -1563,7 +1563,7 @@ class e_db_pdo implements e_db
 	* @access private
 	* @return mixed the name of the language table (eg. lan_french_news) or an array of all matching language tables. (with mprefix)
 	*/
-	function hasLanguage($table, $multiple=false)
+	public function hasLanguage($table, $multiple=false)
 	{
 		//When running a multi-language site with english included. English must be the main site language.
 		// WARNING!!! FALSE is critical important - if missed, expect dead loop (prefs are calling db handler as well when loading)
@@ -2344,7 +2344,16 @@ class e_db_pdo implements e_db
 	}
 
 
-
+	/**
+	 * Drop/delete table and all it's data
+	 * @param string $table name without the prefix
+	 * @return bool|int
+	 */
+	public function dropTable($table)
+	{
+		$name = $this->mySQLPrefix.strtolower($table);
+		return $this->gen("DROP TABLE IF EXISTS ".$name);
+	}
 
 	/**
 	 * Dump MySQL Table(s) to a file in the Backup folder.
@@ -2530,16 +2539,20 @@ class e_db_pdo implements e_db
 		$this->mySQLlastErrText = '';
 	}
 
-	function getLastQuery()
+	/**
+	 * Returns the last database query used.
+	 * @return string
+	 */
+	public function getLastQuery()
 	{
 		return $this->mySQLlastQuery;
 	}
 
+
+
 	private function setSQLMode()
 	{
-
 		$this->db_Query("SET SESSION sql_mode='NO_ENGINE_SUBSTITUTION';");
-
 	}
 
 
@@ -2554,7 +2567,6 @@ class e_db_pdo implements e_db
 		$this->db_Query("SET NAMES `$charset`");
 
 		$this->mySQLcharset = $charset;
-
 	}
 
 
@@ -2563,6 +2575,25 @@ class e_db_pdo implements e_db
 		return $this->mySQLcharset;
 	}
 
+
+	/**
+	 * Set the database language
+	 * @param string $lang French, German etc.
+	 */
+	public function setLanguage($lang)
+	{
+		$this->mySQLlanguage = $lang;
+	}
+
+	/**
+	 * Get the current database language. eg. English, French etc.
+	 * @return string
+	 */
+	public function getLanguage()
+	{
+		return $this->mySQLlanguage;
+	}
+
 	/**
 	 *	Get the _FIELD_DEFS and _NOTNULL definitions for a table
 	 *<code>