diff --git a/b2-include/b2functions.php b/b2-include/b2functions.php index eee0fc8869..936ab786bd 100644 --- a/b2-include/b2functions.php +++ b/b2-include/b2functions.php @@ -370,7 +370,7 @@ function strip_all_but_one_link($text, $mylink) { function get_lastpostdate() { - global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow; + global $tableposts, $cache_lastpostdate, $use_cache, $time_difference, $pagenow, $wpdb; if ((!isset($cache_lastpostdate)) OR (!$use_cache)) { $now = date("Y-m-d H:i:s",(time() + ($time_difference * 3600))); if ($pagenow != 'b2edit.php') { @@ -378,11 +378,8 @@ function get_lastpostdate() { } else { $showcatzero = ''; } - $sql = "SELECT * FROM $tableposts WHERE $showcatzero post_date <= '$now' ORDER BY post_date DESC LIMIT 1"; - $result = mysql_query($sql) or die("Your SQL query:
$sql

MySQL said:
".mysql_error()); + $lastpostdate = $wpdb->get_var("SELECT post_date FROM $tableposts WHERE $showcatzero post_date <= '$now' ORDER BY post_date DESC LIMIT 1"); ++$querycount; - $myrow = mysql_fetch_object($result); - $lastpostdate = $myrow->post_date; $cache_lastpostdate = $lastpostdate; // echo $lastpostdate; } else { @@ -536,12 +533,10 @@ function get_postdata2($postid=0) { // less flexible, but saves mysql queries } function get_commentdata($comment_ID,$no_cache=0) { // less flexible, but saves mysql queries - global $postc,$id,$commentdata,$tablecomments,$querycount; + global $postc,$id,$commentdata,$tablecomments,$querycount, $wpdb; if ($no_cache) { - $query="SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID"; - $result=mysql_query($query); + $myrow = $wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID", ARRAY_A); ++$querycount; - $myrow = mysql_fetch_array($result); } else { $myrow['comment_ID']=$postc->comment_ID; $myrow['comment_post_ID']=$postc->comment_post_ID; @@ -564,12 +559,11 @@ function get_commentdata($comment_ID,$no_cache=0) { // less flexible, but saves } function get_catname($cat_ID) { - global $tablecategories,$cache_catnames,$use_cache,$querycount; + global $tablecategories,$cache_catnames,$use_cache,$querycount, $wpdb; if ((!$cache_catnames) || (!$use_cache)) { - $sql = "SELECT * FROM $tablecategories"; - $result = mysql_query($sql) or die('Oops, couldn\'t query the db for categories.'); - $querycount; - while ($post = mysql_fetch_object($result)) { + $results = $wpdb->get_results("SELECT * FROM $tablecategories") or die('Oops, couldn\'t query the db for categories.'); + $querycount++; + foreach ($results as $post) { $cache_catnames[$post->cat_ID] = $post->cat_name; } } @@ -583,16 +577,16 @@ function profile($user_login) { } function dropdown_categories($blog_ID=1, $default=1) { - global $postdata,$tablecategories,$mode,$querycount; + global $postdata,$tablecategories,$mode,$querycount, $wpdb; $query="SELECT * FROM $tablecategories"; - $result=mysql_query($query); + $results = $wpdb->get_results($query); ++$querycount; $width = ($mode=="sidebar") ? "100%" : "170px"; echo '