From 2c50a0651750c0d7ff048d700c376e0040c142dd Mon Sep 17 00:00:00 2001
From: Cameron <e107inc@gmail.com>
Date: Mon, 15 Feb 2016 00:56:08 -0800
Subject: [PATCH] Deprecated Function cleanup and PHP Notice removal.

---
 class2.php                                    | 18 +++++-----
 .../shortcodes/batch/admin_shortcodes.php     | 14 ++++----
 e107_core/shortcodes/single/iconpicker.php    |  2 +-
 e107_core/shortcodes/single/imageselector.php |  2 +-
 e107_core/shortcodes/single/sublinks.php      |  8 ++---
 e107_core/shortcodes/single/usersearch.php    |  2 +-
 e107_core/url/news/sef_full_url.php           |  8 ++---
 e107_core/url/news/sef_noid_url.php           | 26 +++++++-------
 e107_core/url/user/rewrite_url.php            |  4 +--
 e107_handlers/cron_class.php                  |  4 +--
 e107_handlers/db_table_admin_class.php        |  6 ++--
 e107_handlers/iphandler_class.php             |  2 +-
 e107_handlers/mail_manager_class.php          |  4 +--
 e107_handlers/mailout_admin_class.php         |  2 +-
 e107_handlers/mailout_class.php               |  2 +-
 e107_handlers/media_class.php                 |  2 +-
 e107_handlers/model_class.php                 |  4 +--
 e107_handlers/mysql_class.php                 | 35 +++++++++++--------
 e107_handlers/plugin_class.php                |  2 +-
 e107_plugins/forum/forum.php                  |  2 +-
 index.php                                     |  4 +--
 install.php                                   |  2 +-
 userposts.php                                 |  2 +-
 usersettings.php                              |  8 ++---
 24 files changed, 85 insertions(+), 80 deletions(-)

diff --git a/class2.php b/class2.php
index caf62bc1a..326f8a181 100644
--- a/class2.php
+++ b/class2.php
@@ -1042,7 +1042,7 @@ if(($pref['membersonly_enabled'] && !isset($_E107['allow_guest'])) || ($pref['ma
 
 if(!isset($_E107['no_prunetmp']))
 {
-	$sql->db_Delete('tmp', 'tmp_time < '.(time() - 300)." AND tmp_ip!='data' AND tmp_ip!='submitted_link'");
+	$sql->delete('tmp', 'tmp_time < '.(time() - 300)." AND tmp_ip!='data' AND tmp_ip!='submitted_link'");
 }
 
 
@@ -1076,7 +1076,7 @@ if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'ses
 	// TODO - should be done inside online handler, more core areas need it (session handler for example)
 	if (isset($pref['track_online']) && $pref['track_online'])
 	{
-		$sql->db_Update('online', "online_user_id = 0, online_pagecount=online_pagecount+1 WHERE online_user_id = '{$udata}'");
+		$sql->update('online', "online_user_id = 0, online_pagecount=online_pagecount+1 WHERE online_user_id = '{$udata}'");
 	}
 	
 	// earlier event trigger with user data still available 
@@ -1505,9 +1505,9 @@ function getperms($arg, $ap = ADMINPERMS)
 		$sql = e107::getDb('psql');
 
 		// FIXME - cache it, avoid sql query here
-		if ($sql->db_Select('plugin', 'plugin_id', "plugin_path = '".$matches[2]."' LIMIT 1 "))
+		if ($sql->select('plugin', 'plugin_id', "plugin_path = '".$matches[2]."' LIMIT 1 "))
 		{
-			$row = $sql->db_Fetch();
+			$row = $sql->fetch();
 			$arg = 'P'.$row['plugin_id'];
 		}
 	}
@@ -1603,7 +1603,7 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '')
 		default:
 			$_user_pref = $tp->toDB($user_pref, true, true, 'pReFs');
 			$tmp = $eArrayStorage->WriteArray($_user_pref);
-			$sql->db_Update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid));
+			$sql->update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid));
 			return $tmp;
 			break;
 	}
@@ -1654,8 +1654,8 @@ class floodprotect
 
 		if (FLOODPROTECT == true)
 		{
-			$sql->db_Select($table, '*', 'ORDER BY '.$orderfield.' DESC LIMIT 1', 'no_where');
-			$row=$sql->db_Fetch();
+			$sql->select($table, '*', 'ORDER BY '.$orderfield.' DESC LIMIT 1', 'no_where');
+			$row=$sql->fetch();
 			return ($row[$orderfield] > (time() - FLOODTIMEOUT) ? false : true);
 		}
 		else
@@ -2055,9 +2055,9 @@ function force_userupdate($currentUser)
 
 	if (!e107::getPref('disable_emailcheck',TRUE) && !trim($currentUser['user_email'])) return TRUE;
 
-	if(e107::getDb()->db_Select('user_extended_struct', 'user_extended_struct_applicable, user_extended_struct_write, user_extended_struct_name, user_extended_struct_type', 'user_extended_struct_required = 1 AND user_extended_struct_applicable != '.e_UC_NOBODY))
+	if(e107::getDb()->select('user_extended_struct', 'user_extended_struct_applicable, user_extended_struct_write, user_extended_struct_name, user_extended_struct_type', 'user_extended_struct_required = 1 AND user_extended_struct_applicable != '.e_UC_NOBODY))
 	{
-		while($row = e107::getDb()->db_Fetch())
+		while($row = e107::getDb()->fetch())
 		{
 			if (!check_class($row['user_extended_struct_applicable'])) { continue; }		// Must be applicable to this user class
 			if (!check_class($row['user_extended_struct_write'])) { continue; }				// And user must be able to change it
diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php
index 4ac802c30..ab9c61677 100644
--- a/e107_core/shortcodes/batch/admin_shortcodes.php
+++ b/e107_core/shortcodes/batch/admin_shortcodes.php
@@ -539,16 +539,16 @@ class admin_shortcodes
 					if (e_QUERY == 'logall')
 					{
 						$text .= "<div id='adminlog'>";
-						$cnt = $sql -> db_Select('admin_log', '*', "ORDER BY `dblog_datestamp` DESC", 'no_where');
+						$cnt = $sql ->select('admin_log', '*', "ORDER BY `dblog_datestamp` DESC", 'no_where');
 					}
 					else
 					{
 						$text .= "<div style='display: none;' id='adminlog'>";
-						$cnt = $sql -> db_Select('admin_log', '*', 'ORDER BY `dblog_datestamp` DESC LIMIT 0,10', 'no_where');
+						$cnt = $sql ->select('admin_log', '*', 'ORDER BY `dblog_datestamp` DESC LIMIT 0,10', 'no_where');
 					}
 					$text .= ($cnt) ? '<ul>' : '';
 					$gen = e107::getDateConvert();
-					while ($row = $sql -> db_Fetch())
+					while ($row = $sql ->fetch())
 					{
 						$datestamp = $gen->convert_date($row['dblog_datestamp'], 'short');
 						$text .= "<li>{$datestamp} - {$row['dblog_title']}</li>";
@@ -832,7 +832,7 @@ class admin_shortcodes
 			$xml->filter = array('@attributes' => FALSE, 'administration' => FALSE);	// .. and they're all going to need the same filter
 
 			$nav_sql = new db;
-			if ($nav_sql -> db_Select('plugin', '*', 'plugin_installflag=1'))
+			if ($nav_sql ->select('plugin', '*', 'plugin_installflag=1'))
 			{
 				$tmp = array();
 				$e107_var['plugm']['text'] = ADLAN_95;
@@ -844,7 +844,7 @@ class admin_shortcodes
 				$tmp['plugm']['link'] = e_ADMIN.'plugin.php';
 				$tmp['plugm']['perm'] = 'P';
 
-				while($rowplug = $nav_sql -> db_Fetch())
+				while($rowplug = $nav_sql ->fetch())
 				{
 					$plugin_id = $rowplug['plugin_id'];
 					$plugin_path = $rowplug['plugin_path'];
@@ -897,9 +897,9 @@ class admin_shortcodes
 				if (strstr(e_SELF, '/admin.php'))
 				{
 					global $sql;
-					if ($sql -> db_Select('plugin', '*', 'plugin_installflag=1'))
+					if ($sql ->select('plugin', '*', 'plugin_installflag=1'))
 					{
-						while($rowplug = $sql -> db_Fetch())
+						while($rowplug = $sql->fetch())
 						{
 							extract($rowplug);
 							if(varset($rowplug[1]))
diff --git a/e107_core/shortcodes/single/iconpicker.php b/e107_core/shortcodes/single/iconpicker.php
index 4a5f8f978..16f066ea7 100644
--- a/e107_core/shortcodes/single/iconpicker.php
+++ b/e107_core/shortcodes/single/iconpicker.php
@@ -30,7 +30,7 @@ function iconpicker_shortcode($parm)
 		
 		if($sql->gen($qry))
 		{
-			while($row = $sql->db_Fetch())
+			while($row = $sql->fetch())
 			{
 				list($tmp,$tmp2,$size) = explode("_",$row['media_category']);
 				
diff --git a/e107_core/shortcodes/single/imageselector.php b/e107_core/shortcodes/single/imageselector.php
index 18f91dfb3..a9738c6dd 100644
--- a/e107_core/shortcodes/single/imageselector.php
+++ b/e107_core/shortcodes/single/imageselector.php
@@ -44,7 +44,7 @@ function imageselector_shortcode($parm = '', $mod = '')
 			// FIXME - media_type=image?
 			if($sql->gen($qry))
 			{
-				while($row = $sql->db_Fetch())
+				while($row = $sql->fetch())
 				{
 					//$imagelist[$row['media_category']][$row['media_url']] = $row['media_name']. " (".$row['media_dimensions'].") ";
 					$imagelist[$row['media_category']][] = array('path' => $row['media_url'], 'fname' => $row['media_name']. " (".$row['media_dimensions'].") ");
diff --git a/e107_core/shortcodes/single/sublinks.php b/e107_core/shortcodes/single/sublinks.php
index 9e2726f0a..970d7d748 100644
--- a/e107_core/shortcodes/single/sublinks.php
+++ b/e107_core/shortcodes/single/sublinks.php
@@ -24,12 +24,12 @@ function sublinks_shortcode($parm)
 
 	$text = "\n\n<!-- Sublinks Start -->\n\n";
     $text .= $style['prelink'];
-    $sql->db_Select("links", "link_id","link_url= '{$page}' AND link_category = {$cat} LIMIT 1");
-    $row = $sql->db_Fetch();
+    $sql->select("links", "link_id","link_url= '{$page}' AND link_category = {$cat} LIMIT 1");
+    $row = $sql->fetch();
     $parent = $row['link_id'];
 
- 	$link_total = $sql->db_Select("links", "*", "link_class IN (".USERCLASS_LIST.") AND link_parent={$parent} ORDER BY link_order ASC");
-	while($linkInfo = $sql->db_Fetch())
+ 	$link_total = $sql->select("links", "*", "link_class IN (".USERCLASS_LIST.") AND link_parent={$parent} ORDER BY link_order ASC");
+	while($linkInfo = $sql->fetch())
 	{
  		$text .= $sublinks->makeLink($linkInfo,TRUE, $style, false);
 	}
diff --git a/e107_core/shortcodes/single/usersearch.php b/e107_core/shortcodes/single/usersearch.php
index 8387ba9d8..ae84df63e 100644
--- a/e107_core/shortcodes/single/usersearch.php
+++ b/e107_core/shortcodes/single/usersearch.php
@@ -46,7 +46,7 @@ function usersearch_shortcode($parm)
 	if($sql->gen($qry))
 	{
 		if($emailSrch) $info_field = 'user_email';
-		while($row = $sql->db_Fetch())
+		while($row = $sql->fetch())
 		{
 			$ret .= "<li id='{$row['user_id']}'>{$row[$search_field]}<span class='informal'> [{$row['user_id']}] ".$row[$info_field].$email." </span></li>";
 		}
diff --git a/e107_core/url/news/sef_full_url.php b/e107_core/url/news/sef_full_url.php
index 0c7078ba5..f7a9eccb7 100644
--- a/e107_core/url/news/sef_full_url.php
+++ b/e107_core/url/news/sef_full_url.php
@@ -94,9 +94,9 @@ class core_news_sef_full_url extends eUrlConfig
 		
 		$sql = e107::getDb('url');
 		$name = e107::getParser()->toDB($name);
-		if($sql->db_Select('news', 'news_id', "news_sef='{$name}'")) // TODO - it'll be news_sef (new) field
+		if($sql->select('news', 'news_id', "news_sef='{$name}'")) // TODO - it'll be news_sef (new) field
 		{
-			$name = $sql->db_Fetch();
+			$name = $sql->fetch();
 			$request->setRequestParam('name', $name['news_id']);
 		}
 		else $request->setRequestParam('name', 0);
@@ -122,9 +122,9 @@ class core_news_sef_full_url extends eUrlConfig
 		
 		$sql = e107::getDb('url');
 		$id = e107::getParser()->toDB($name);
-		if($sql->db_Select('news_category', 'category_id', "category_sef='{$name}'")) // TODO - it'll be category_sef (new) field
+		if($sql->select('news_category', 'category_id', "category_sef='{$name}'")) // TODO - it'll be category_sef (new) field
 		{
-			$name = $sql->db_Fetch();
+			$name = $sql->fetch();
 			$request->setRequestParam('name', $name['category_id']);
 		}
 		else $request->setRequestParam('name', 0);
diff --git a/e107_core/url/news/sef_noid_url.php b/e107_core/url/news/sef_noid_url.php
index 8ae79aa05..4bf3dd937 100644
--- a/e107_core/url/news/sef_noid_url.php
+++ b/e107_core/url/news/sef_noid_url.php
@@ -191,8 +191,8 @@ class core_news_sef_noid_url extends eUrlConfig
 		switch ($parts[0]) 
 		{
 			# map to list.xxx.xxx
-			case 'short':
-			case 'category':
+			case 'short':
+			case 'category':
 				# Hardcoded leading string for categories, could be pref or LAN constant
 				if(!vartrue($parts[1]))
 				{
@@ -202,7 +202,7 @@ class core_news_sef_noid_url extends eUrlConfig
 				else 
 				{
 					if(!is_numeric($parts[1])) $id = $this->categoryIdByTitle($parts[1]);
-					else $id = intval($parts[1]);
+					else $id = intval($parts[1]);
 				}
 				if(!$id)
 				{
@@ -211,8 +211,8 @@ class core_news_sef_noid_url extends eUrlConfig
 				}
 				$action = $parts[0] == 'short' ? 'cat' : 'list';
 				$this->legacyQueryString = $action.'.'.$id.'.'.$page;
-				return 'item/list';
-			break;
+				return 'item/list';
+			break;
 			
 			# could be pref or LAN constant
 			case 'day':
@@ -251,10 +251,10 @@ class core_news_sef_noid_url extends eUrlConfig
 				return 'list/tag';
 			break;
 			
-			# force not found
-			default:
-				return false;
-			break;
+			# force not found
+			default:
+				return false;
+			break;
 		}
 		
 		return false;
@@ -290,9 +290,9 @@ class core_news_sef_noid_url extends eUrlConfig
 		$sql = e107::getDb('url');
 		$tp = e107::getParser();
 		$id = $tp->toDB($id);
-		if($sql->db_Select('news', 'news_id', "news_sef='{$id}'")) 
+		if($sql->select('news', 'news_id', "news_sef='{$id}'"))
 		{
-			$id = $sql->db_Fetch();
+			$id = $sql->fetch();
 			return $id['news_id'];
 		}
 		return false;
@@ -304,9 +304,9 @@ class core_news_sef_noid_url extends eUrlConfig
 		$sql = e107::getDb('url');
 		$tp = e107::getParser();
 		$id = $tp->toDB($id);
-		if($sql->db_Select('news_category', 'category_id', "category_sef='{$id}'")) 
+		if($sql->select('news_category', 'category_id', "category_sef='{$id}'"))
 		{
-			$id = $sql->db_Fetch();
+			$id = $sql->fetch();
 			return $id['category_id'];
 		}
 		return false;
diff --git a/e107_core/url/user/rewrite_url.php b/e107_core/url/user/rewrite_url.php
index 06635f272..8566b3cd3 100644
--- a/e107_core/url/user/rewrite_url.php
+++ b/e107_core/url/user/rewrite_url.php
@@ -92,9 +92,9 @@ class core_user_rewrite_url extends eUrlConfig
 		
 		$sql = e107::getDb('url');
 		$name = e107::getParser()->toDB($name);
-		if($sql->db_Select('user', 'user_id', "user_name='{$name}'")) // XXX - new user_sef field? Discuss.
+		if($sql->select('user', 'user_id', "user_name='{$name}'")) // XXX - new user_sef field? Discuss.
 		{
-			$name = $sql->db_Fetch();
+			$name = $sql->fetch();
 			$request->setRequestParam('id', $name['user_id']);
 		}
 	}
diff --git a/e107_handlers/cron_class.php b/e107_handlers/cron_class.php
index dfe3f1030..01de7f1e1 100644
--- a/e107_handlers/cron_class.php
+++ b/e107_handlers/cron_class.php
@@ -336,14 +336,14 @@ class _system_cron
 			$table = $tab[0];
 			$text = "";
 			
-			$sql->db_Select_gen("SHOW CREATE TABLE `".$table."`");
+			$sql->gen("SHOW CREATE TABLE `".$table."`");
 			$row2 = $sql->db_Fetch();
 			$text .= $row2['Create Table'];
 			$text .= ";\n\n";
 			
 			ob_end_clean(); // prevent memory exhaustian 
 			
-			$count = $sql->db_Select_gen("SELECT * FROM `".$table."`");
+			$count = $sql->gen("SELECT * FROM `".$table."`");
 			$data_array = "";
 		
 			while($row = $sql->db_Fetch())
diff --git a/e107_handlers/db_table_admin_class.php b/e107_handlers/db_table_admin_class.php
index 971411677..bc481010f 100644
--- a/e107_handlers/db_table_admin_class.php
+++ b/e107_handlers/db_table_admin_class.php
@@ -44,9 +44,9 @@ class db_table_admin
 			$prefix = MPREFIX;
 		}
 		//	echo "Get table structure for: {$table_name}, prefix: {$prefix}<br />";
-		$sql->db_Select_gen('SET SQL_QUOTE_SHOW_CREATE = 1');
+		$sql->gen('SET SQL_QUOTE_SHOW_CREATE = 1');
 		$qry = 'SHOW CREATE TABLE `'.$prefix.$table_name."`";
-		if (!($z = $sql->db_Select_gen($qry)))
+		if (!($z = $sql->gen($qry)))
 		{
 			return FALSE;
 		}
@@ -621,7 +621,7 @@ class db_table_admin
 				{
 					return 'Table doesn\'t exist';
 				}
-				if ($sql->db_Select_gen($newStructure[0]))
+				if ($sql->gen($newStructure[0]))
 				{
 					return TRUE;
 				}
diff --git a/e107_handlers/iphandler_class.php b/e107_handlers/iphandler_class.php
index e110574f1..d97066a01 100644
--- a/e107_handlers/iphandler_class.php
+++ b/e107_handlers/iphandler_class.php
@@ -1271,7 +1271,7 @@ class banlistManager
 			}
 		}
 
-		if ($sql->db_Select_gen($qry))
+		if ($sql->gen($qry))
 		{
 			while ($row = $sql->db_Fetch())
 			{
diff --git a/e107_handlers/mail_manager_class.php b/e107_handlers/mail_manager_class.php
index da00c8539..d1358b6bb 100644
--- a/e107_handlers/mail_manager_class.php
+++ b/e107_handlers/mail_manager_class.php
@@ -1615,7 +1615,7 @@ class e107MailManager
 			$query .= " LIMIT {$start}, {$count}";
 		}
 		//echo "{$start}, {$count} Mail query: {$query}<br />";
-		$result = $this->db->db_Select_gen($query);
+		$result = $this->db->gen($query);
 		if ($result !== FALSE)
 		{
 			$this->queryCount[1] = $this->db->total_results;			// Save number of records found
@@ -1684,7 +1684,7 @@ class e107MailManager
 			$query .= " LIMIT {$start}, {$count}";
 		}
 //		echo "{$start}, {$count} Target query: {$query}<br />";
-		$result = $this->db2->db_Select_gen($query);
+		$result = $this->db2->gen($query);
 		if ($result !== FALSE)
 		{
 			$this->queryCount[2] = $this->db2->total_results;			// Save number of records found
diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php
index 584b555e0..b831cfb3b 100644
--- a/e107_handlers/mailout_admin_class.php
+++ b/e107_handlers/mailout_admin_class.php
@@ -1934,7 +1934,7 @@ class mailoutAdminClass extends e107MailManager
 
 		//Finally - check for inconsistent recipient and content status records -
 		// basically verify counts
-		if(($res = $this->db2->db_Select_gen("SELECT COUNT(mr.`mail_status`) AS mr_count, mr.`mail_status`, 
+		if(($res = $this->db2->gen("SELECT COUNT(mr.`mail_status`) AS mr_count, mr.`mail_status`,
 					mc.`mail_source_id`, mc.`mail_togo_count`, mc.`mail_sent_count`, mc.`mail_fail_count`, mc.`mail_bounce_count`, mc.`mail_source_id` FROM `#mail_recipients` AS mr
 					LEFT JOIN `#mail_content` AS mc ON mr.`mail_detail_id` = mc.`mail_source_id` 
 					WHERE mc.`mail_content_status` <= " . MAIL_STATUS_MAX_ACTIVE . "
diff --git a/e107_handlers/mailout_class.php b/e107_handlers/mailout_class.php
index 32331a4cb..ae204b1cc 100644
--- a/e107_handlers/mailout_class.php
+++ b/e107_handlers/mailout_class.php
@@ -216,7 +216,7 @@ class core_mailout
 		
 		e107::getMessage()->addDebug("Selector query: ".$qry);
 
-		if (!( $this->mail_count = $sql->db_Select_gen($qry))) return FALSE;
+		if (!( $this->mail_count = $sql->gen($qry))) return FALSE;
 		$this->mail_read = 0;
 		return $this->mail_count;
 	}
diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php
index 576f1044e..186a08ae9 100644
--- a/e107_handlers/media_class.php
+++ b/e107_handlers/media_class.php
@@ -408,7 +408,7 @@ class e_media
 			$query .= " AND ( ".implode(" OR ",$searchinc)." ) " ;	
 		}
 		
-		return e107::getDb()->db_Select_gen($query);	
+		return e107::getDb()->gen($query);
 		*/
 	}
 	
diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php
index 5ebfbd7bc..4d9bba3ec 100644
--- a/e107_handlers/model_class.php
+++ b/e107_handlers/model_class.php
@@ -1676,7 +1676,7 @@ class e_model extends e_object
 	/**
 	 * Set parameter array
 	 * Core implemented:
-	 * - db_query: string db query to be passed to load() ($sql->db_Select_gen())
+	 * - db_query: string db query to be passed to load() ($sql->gen())
 	 * - db_query
 	 * - db_fields
 	 * - db_where
@@ -3237,7 +3237,7 @@ class e_tree_model extends e_front_model
 			$sql = e107::getDb($this->getParam('model_class', 'e_model'));
 			$this->_total = $sql->total_results = false;
 
-			if($sql->db_Select_gen($this->getParam('db_query'), $this->getParam('db_debug') ? true : false))
+			if($sql->gen($this->getParam('db_query'), $this->getParam('db_debug') ? true : false))
 			{
 				$this->_total = is_integer($sql->total_results) ? $sql->total_results : false; //requires SQL_CALC_FOUND_ROWS in query - see db handler
 				while($tmp = $sql->db_Fetch())
diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php
index 954472f9d..7ee874ed2 100644
--- a/e107_handlers/mysql_class.php
+++ b/e107_handlers/mysql_class.php
@@ -1168,41 +1168,46 @@ class e_db_mysql
 			switch ($type)
 			{
 					case 'both':
-					case 3:
+					case 3: // MYSQL_BOTH:
 						$type = ($this->pdo) ? PDO::FETCH_BOTH: MYSQL_BOTH; // 3
 					break;
 
 					case 'num':
-					case 2: 
+					case 2; // MYSQL_NUM: // 2
 						$type = ($this->pdo) ? PDO::FETCH_NUM : MYSQL_NUM;
 					break;
 
 					case 'assoc':
-					case 1: 
+					case 1; //: // 1
 					default:
 						$type =  ($this->pdo) ?  PDO::FETCH_ASSOC : MYSQL_ASSOC;
 					break;
 				}
 		}
-		elseif($this->pdo) // convert type to PDO.
+		else
 		{
-			switch ($type)
+
+			if($this->pdo) // convert type to PDO.
 			{
-				case 'both': // 3
-					$type = PDO::FETCH_BOTH;
-				break;
-				case 'num': // 2
-					$type = PDO::FETCH_NUM;
-				break;
+				switch ($type)
+				{
+					case 'both': // 3
+						$type = PDO::FETCH_BOTH;
+					break;
+
+					case 'num': // 2
+						$type = PDO::FETCH_NUM;
+					break;
+
 					case 'assoc': // 1
-				default:
-					$type = PDO::FETCH_ASSOC;
-				break;
+					default:
+						$type = PDO::FETCH_ASSOC;
+					break;
+				}
 			}
 		}
 
 
-		
 		$b = microtime();
 		if($this->mySQLresult)
 		{
diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php
index ee7a76675..1bfffe83a 100644
--- a/e107_handlers/plugin_class.php
+++ b/e107_handlers/plugin_class.php
@@ -1796,7 +1796,7 @@ class e107plugin
 						}
 						break;
 					case 'mysql': // all should be lowercase
-						if (isset($dv['@attributes']['min_version']) && (version_compare($dv['@attributes']['min_version'], mysql_get_server_info(), '<=') === FALSE))
+						if (isset($dv['@attributes']['min_version']) && (version_compare($dv['@attributes']['min_version'], e107::getDb()->mySqlServerInfo(), '<=') === FALSE))
 						{
 							$error[] = EPL_ADLAN_75.$dv['@attributes']['min_version'];
 							$canContinue = FALSE;
diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php
index 564148af5..ba78f95e7 100644
--- a/e107_plugins/forum/forum.php
+++ b/e107_plugins/forum/forum.php
@@ -144,7 +144,7 @@ $total_topics = $sql->count("forum_thread", "(*)");
 $total_replies = $sql->count("forum_post", "(*)");
 $total_members = $sql->count("user");
 $newest_member = $sql->select("user", "*", "user_ban='0' ORDER BY user_join DESC LIMIT 0,1");
-list($nuser_id, $nuser_name) = $sql->fetch(); // FIXME $nuser_id & $user_name return empty even though print_a($newest_member); returns proper result.
+list($nuser_id, $nuser_name) = $sql->fetch('num'); // FIXME $nuser_id & $user_name return empty even though print_a($newest_member); returns proper result.
 
 if(!defined('e_TRACKING_DISABLED'))
 {
diff --git a/index.php b/index.php
index 798c51ce2..da0b18629 100644
--- a/index.php
+++ b/index.php
@@ -229,7 +229,7 @@
 		
 		if($user_profile->identifier >0)
 		{
-			if (!$sql->db_Select("user", "*", "user_xup = '".$prov_id."' ")) // New User
+			if (!$sql->select("user", "*", "user_xup = '".$prov_id."' ")) // New User
 			{
 				$user_join 				= time();
 				$user_pass 				= md5($user_profile->identifier.$user_join);
@@ -245,7 +245,7 @@
 					'user_xup'			=> $prov_id
 				);
 				
-				if($newid = $sql->db_Insert('user',$insert,true))
+				if($newid = $sql->insert('user',$insert,true))
 				{
 					e107::getEvent()->trigger('usersup', $insert);	
 					if(!USERID)
diff --git a/install.php b/install.php
index b0e85f1ad..aeb2437b2 100644
--- a/install.php
+++ b/install.php
@@ -1791,7 +1791,7 @@ if($this->pdo == true)
 
 		if(!$link)
 		{
-			return nl2br(LANINS_084."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>");
+			return nl2br(LANINS_084."\n\n<b>".LANINS_083."\n</b><i>".e107::getDb()->getLastErrorText()."</i>");
 		}
 
 		$this->dbLink = $link;		// Needed for mysql_close() to work round bug in PHP 5.3
diff --git a/userposts.php b/userposts.php
index c8a0f72de..bece2ba50 100644
--- a/userposts.php
+++ b/userposts.php
@@ -194,7 +194,7 @@ elseif ($action == 'forums')
 	ORDER BY p.post_datestamp DESC LIMIT {$from}, 10
 	";
 
-	if (!$sql->db_Select_gen($qry))
+	if (!$sql->gen($qry))
 	{
 		$ftext .= "<span class='mediumtext'>".UP_LAN_8.'</span>';
 	}
diff --git a/usersettings.php b/usersettings.php
index 07093b55c..f09bfc8b6 100644
--- a/usersettings.php
+++ b/usersettings.php
@@ -452,7 +452,7 @@ if ($dataToSave && !$promptPassword)
 		validatorClass::addFieldTypes($userMethods->userVettingInfo,$changedData);
 
 		// print_a($changedData);
-		if (FALSE === $sql->db_Update('user', $changedData))
+		if (FALSE === $sql->update('user', $changedData))
 		{
 			$message .= '<br />'.LAN_USET_43;
 		}
@@ -476,10 +476,10 @@ if ($dataToSave && !$promptPassword)
 		if (false === $sql->retrieve('user_extended', 'user_extended_id', 'user_extended_id='.$inp))
 		{
 			// ***** Next line creates a record which presumably should be there anyway, so could generate an error if no test first
-			$sql->db_Select_gen("INSERT INTO #user_extended (user_extended_id, user_hidden_fields) values ('".$inp."', '')");
+			$sql->gen("INSERT INTO #user_extended (user_extended_id, user_hidden_fields) values ('".$inp."', '')");
 			//print_a('New extended fields added: '.$inp.'<br />');
 		}
-		if (false === $sql->db_Update('user_extended', $changedEUFData))
+		if (false === $sql->update('user_extended', $changedEUFData))
 		{
 			$message .= '<br />Error updating EUF';
 		}
@@ -582,7 +582,7 @@ if ($dataToSave && !$promptPassword)
 		// If user has changed display name, update the record in the online table
 	if (isset($changedUserData['user_name']) && !$_uid)
 	{
-		$sql->db_Update('online', "online_user_id = '".USERID.".".$changedUserData['user_name']."' WHERE online_user_id = '".USERID.".".USERNAME."'");
+		$sql->update('online', "online_user_id = '".USERID.".".$changedUserData['user_name']."' WHERE online_user_id = '".USERID.".".USERNAME."'");
 	}