Changeset 1355 for trunk/wp-includes/functions-post.php
- Timestamp:
- 05/24/2004 08:22:18 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions-post.php
r1353 r1355 7 7 */ 8 8 function wp_insert_post($postarr = array()) { 9 global $wpdb, $ tableposts, $post_default_category;9 global $wpdb, $post_default_category; 10 10 11 11 // export array as variables … … 32 32 $post_date_gmt = get_gmt_from_date($post_date); 33 33 34 $sql = "INSERT INTO $ tableposts34 $sql = "INSERT INTO $wpdb->posts 35 35 (post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name) 36 36 VALUES ('$post_author', '$post_date', '$post_date_gmt', '$post_date', '$post_date_gmt', '$post_content', '$post_title', '$post_excerpt', '$post_cat', '$post_status', '$post_name')"; … … 50 50 51 51 function wp_get_single_post($postid = 0, $mode = OBJECT) { 52 global $wpdb , $tableposts;53 54 $sql = "SELECT * FROM $ tableposts WHERE ID=$postid";52 global $wpdb; 53 54 $sql = "SELECT * FROM $wpdb->posts WHERE ID=$postid"; 55 55 $result = $wpdb->get_row($sql, $mode); 56 56 … … 62 62 63 63 function wp_get_recent_posts($num = 10) { 64 global $wpdb , $tableposts;64 global $wpdb; 65 65 66 66 // Set the limit clause, if we got a limit … … 69 69 } 70 70 71 $sql = "SELECT * FROM $ tableposts ORDER BY post_date DESC $limit";71 $sql = "SELECT * FROM $wpdb->posts ORDER BY post_date DESC $limit"; 72 72 $result = $wpdb->get_results($sql,ARRAY_A); 73 73 … … 76 76 77 77 function wp_update_post($postarr = array()) { 78 global $wpdb , $tableposts;78 global $wpdb; 79 79 80 80 // First get all of the original fields … … 97 97 $post_modified_gmt = current_time('mysql', 1); 98 98 99 $sql = "UPDATE $ tableposts99 $sql = "UPDATE $wpdb->posts 100 100 SET post_content = '$post_content', 101 101 post_title = '$post_title', … … 119 119 120 120 function wp_get_post_cats($blogid = '1', $post_ID = 0) { 121 global $wpdb , $tablepost2cat;121 global $wpdb; 122 122 123 123 $sql = "SELECT category_id 124 FROM $ tablepost2cat124 FROM $wpdb->post2cat 125 125 WHERE post_id = $post_ID 126 126 ORDER BY category_id"; … … 132 132 133 133 function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { 134 global $wpdb , $tablepost2cat;134 global $wpdb; 135 135 // If $post_categories isn't already an array, make it one: 136 136 if (!is_array($post_categories)) { … … 146 146 $old_categories = $wpdb->get_col(" 147 147 SELECT category_id 148 FROM $ tablepost2cat148 FROM $wpdb->post2cat 149 149 WHERE post_id = $post_ID"); 150 150 … … 169 169 foreach ($delete_cats as $del) { 170 170 $wpdb->query(" 171 DELETE FROM $ tablepost2cat171 DELETE FROM $wpdb->post2cat 172 172 WHERE category_id = $del 173 173 AND post_id = $post_ID … … 186 186 foreach ($add_cats as $new_cat) { 187 187 $wpdb->query(" 188 INSERT INTO $ tablepost2cat (post_id, category_id)188 INSERT INTO $wpdb->post2cat (post_id, category_id) 189 189 VALUES ($post_ID, $new_cat)"); 190 190 … … 195 195 196 196 function wp_delete_post($postid = 0) { 197 global $wpdb , $tableposts, $tablepost2cat;198 199 $sql = "DELETE FROM $ tablepost2cat WHERE post_id = $postid";197 global $wpdb; 198 199 $sql = "DELETE FROM $wpdb->post2cat WHERE post_id = $postid"; 200 200 $wpdb->query($sql); 201 201 202 $sql = "DELETE FROM $ tableposts WHERE ID = $postid";202 $sql = "DELETE FROM $wpdb->posts WHERE ID = $postid"; 203 203 204 204 $wpdb->query($sql); … … 216 216 function post_permalink($post_ID=0, $mode = 'id') { 217 217 global $wpdb; 218 global $tableposts;219 218 global $querystring_start, $querystring_equal, $querystring_separator; 220 219 … … 266 265 // Get the name of a category from its ID 267 266 function get_cat_name($cat_id) { 268 global $wpdb ,$tablecategories;267 global $wpdb; 269 268 270 269 $cat_id -= 0; // force numeric 271 $name = $wpdb->get_var("SELECT cat_name FROM $ tablecategories WHERE cat_ID=$cat_id");270 $name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat_id"); 272 271 273 272 return $name; … … 276 275 // Get the ID of a category from its name 277 276 function get_cat_ID($cat_name='General') { 278 global $wpdb ,$tablecategories;279 280 $cid = $wpdb->get_var("SELECT cat_ID FROM $ tablecategories WHERE cat_name='$cat_name'");277 global $wpdb; 278 279 $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); 281 280 282 281 return $cid?$cid:1; // default to cat 1
Note: See TracChangeset
for help on using the changeset viewer.