Removed mysql direct calls

git-svn-id: https://develop.svn.wordpress.org/trunk@282 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mike Little
2003-07-30 23:44:08 +00:00
parent 210fd94760
commit 5e25b738cf
5 changed files with 27 additions and 33 deletions

View File

@@ -47,8 +47,7 @@ case 'addcat':
$cat_name=addslashes($HTTP_POST_VARS["cat_name"]);
$query = "INSERT INTO $tablecategories (cat_ID,cat_name) VALUES ('0', '$cat_name')";
$result = mysql_query($query) or die("Couldn't add category <b>$cat_name</b>");
$wpdb->query("INSERT INTO $tablecategories (cat_ID,cat_name) VALUES ('0', '$cat_name')");
header('Location: b2categories.php');
@@ -68,12 +67,9 @@ case 'Delete':
if ($user_level < 3)
die ('Cheatin&#8217; uh?');
$query = "DELETE FROM $tablecategories WHERE cat_ID = $cat_ID";
$result = mysql_query($query) or die("Couldn't delete category <b>$cat_name</b>".mysql_error());
$query = "UPDATE $tableposts SET post_category='1' WHERE post_category='$cat_ID'";
$result = mysql_query($query) or die("Couldn't reset category on posts where category was <b>$cat_name</b>");
$wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID");
$wpdb->query("UPDATE $tableposts SET post_category='1' WHERE post_category='$cat_ID'");
header('Location: b2categories.php');
@@ -113,8 +109,7 @@ case 'editedcat':
$cat_name = addslashes($HTTP_POST_VARS["cat_name"]);
$cat_ID = addslashes($HTTP_POST_VARS["cat_ID"]);
$query = "UPDATE $tablecategories SET cat_name='$cat_name' WHERE cat_ID = $cat_ID";
$result = mysql_query($query) or die("Couldn't edit category <b>$cat_name</b>: ".mysql_error());
$wpdb->query("UPDATE $tablecategories SET cat_name='$cat_name' WHERE cat_ID = $cat_ID");
header('Location: b2categories.php');

View File

@@ -148,10 +148,9 @@ if ($i == "ASC")
if ($archive_mode == "monthly") {
echo "<select name=\"m\" style=\"width:120px;\">";
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
$querycount++;
$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
while($arc_row = mysql_fetch_array($arc_result)) {
$arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts ORDER BY post_date DESC",ARRAY_A);
foreach ($arc_result as $arc_row) {
$arc_year = $arc_row["YEAR(post_date)"];
$arc_month = $arc_row["MONTH(post_date)"];
echo "<option value=\"$arc_year".zeroise($arc_month,2)."\">";
@@ -161,10 +160,9 @@ if ($i == "ASC")
} elseif ($archive_mode == "daily") {
echo "<select name=\"d\" style=\"width:120px;\">";
$archive_day_date_format = "Y/m/d";
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts ORDER BY post_date DESC";
$querycount++;
$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
while($arc_row = mysql_fetch_array($arc_result)) {
$arc_result=$wpdb->get_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts ORDER BY post_date DESC", ARRAY_A);
foreach ($arc_result as $arc_row) {
$arc_year = $arc_row["YEAR(post_date)"];
$arc_month = $arc_row["MONTH(post_date)"];
$arc_dayofmonth = $arc_row["DAYOFMONTH(post_date)"];
@@ -180,11 +178,10 @@ if ($i == "ASC")
$archive_week_start_date_format = "Y/m/d";
$archive_week_end_date_format = "Y/m/d";
$archive_week_separator = " - ";
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts ORDER BY post_date DESC";
$querycount++;
$arc_result=mysql_query($arc_sql) or die($arc_sql."<br />".mysql_error());
$arc_result=$wpdb->geT_results("SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts ORDER BY post_date DESC", ARRAY_A);
$arc_w_last = '';
while($arc_row = mysql_fetch_array($arc_result)) {
foreach ($arc_result as $arc_row) {
$arc_year = $arc_row["YEAR(post_date)"];
$arc_w = $arc_row["WEEK(post_date)"];
if ($arc_w != $arc_w_last) {
@@ -201,10 +198,9 @@ if ($i == "ASC")
} elseif ($archive_mode == "postbypost") {
echo '<input type="hidden" name="more" value="1" />';
echo '<select name="p" style="width:120px;">';
$requestarc = " SELECT ID,post_date,post_title FROM $tableposts ORDER BY post_date DESC";
$querycount++;
$resultarc = mysql_query($requestarc);
while($row=mysql_fetch_object($resultarc)) {
$querycount++;
$resultarc = $wpdb->get_results("SELECT ID,post_date,post_title FROM $tableposts ORDER BY post_date DESC");
foreach ($resultarc as $row) {
if ($row->post_date != "0000-00-00 00:00:00") {
echo "<option value=\"".$row->ID."\">";
if (strip_tags($row->post_title)) {

View File

@@ -96,7 +96,7 @@ case 'update':
$query = "UPDATE $tableusers SET user_firstname='$newuser_firstname', ".$updatepassword."user_lastname='$newuser_lastname', user_nickname='$newuser_nickname', user_icq='$newuser_icq', user_email='$newuser_email', user_url='$newuser_url', user_aim='$newuser_aim', user_msn='$newuser_msn', user_yim='$newuser_yim', user_idmode='$newuser_idmode' WHERE ID = $user_ID";
$result = $wpdb->query($query);
if (!$result) {
die ("<strong>ERROR</strong>: couldn't update your profile... please contact the <a href=\"mailto:$admin_email\">webmaster</a> !<br /><br />$query<br /><br />".mysql_error());
die ("<strong>ERROR</strong>: couldn't update your profile... please contact the <a href=\"mailto:$admin_email\">webmaster</a> !<br /><br />$query<br /><br />");
}
?>