Make WordPress Core

Changeset 10910


Ignore:
Timestamp:
04/10/2009 09:56:30 PM (15 years ago)
Author:
ryan
Message:

Store field types in wpdb object. Props mdawaffe. see #7171

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-db.php

    r10907 r10910  
    254254    var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',
    255255            'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
     256
     257    /**
     258     * Format specifiers for DB columns. Columns not listed here default to %s.  Initialized in wp-settings.php.
     259     *
     260     * Keys are colmn names, values are format types: 'ID' => '%d'
     261     *
     262     * @since 2.8.0
     263     * @see wpdb:prepare()
     264     * @see wpdb:insert()
     265     * @see wpdb:update()
     266     * @access public
     267     * @war array
     268     */
     269    var $field_type = array();
    256270
    257271    /**
     
    704718     */
    705719    function insert($table, $data, $format = null) {
    706         global $db_field_types;
    707 
    708720        $formats = $format = (array) $format;
    709721        $fields = array_keys($data);
     
    712724            if ( !empty($format) )
    713725                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
    714             elseif ( isset($db_field_types[$field]) )
    715                 $form = $db_field_types[$field];
     726            elseif ( isset($this->field_types[$field]) )
     727                $form = $this->field_types[$field];
    716728            else
    717729                $form = '%s';
     
    735747     */
    736748    function update($table, $data, $where, $format = null, $where_format = null) {
    737         global $db_field_types;
    738 
    739749        if ( !is_array( $where ) )
    740750            return false;
     
    745755            if ( !empty($format) )
    746756                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
    747             elseif ( isset($db_field_types[$field]) )
    748                 $form = $db_field_types[$field];
     757            elseif ( isset($this->field_types[$field]) )
     758                $form = $this->field_types[$field];
    749759            else
    750760                $form = '%s';
     
    756766            if ( !empty($where_format) )
    757767                $form = ( $form = array_shift($where_formats) ) ? $form : $where_format[0];
    758             elseif ( isset($db_field_types[$field]) )
    759                 $form = $db_field_types[$field];
     768            elseif ( isset($this->field_types[$field]) )
     769                $form = $this->field_types[$field];
    760770            else
    761771                $form = '%s';
  • trunk/wp-settings.php

    r10892 r10910  
    248248require (ABSPATH . WPINC . '/classes.php');
    249249
     250require_wp_db();
     251
     252if ( !empty($wpdb->error) )
     253    dead_db();
     254
    250255/**
    251256 * Format specifiers for DB columns. Columns not listed here default to %s.
    252257 * @since 2.8.0
    253  */
    254 $db_field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
     258 * @see wpdb:$field_types
     259 * @see wpdb:prepare()
     260 * @see wpdb:insert()
     261 * @see wpdb:update()
     262 */
     263$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
    255264    'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    256265    'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    257266    'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
    258 
    259 require_wp_db();
    260 
    261 if ( !empty($wpdb->error) )
    262     dead_db();
    263267
    264268$prefix = $wpdb->set_prefix($table_prefix);
Note: See TracChangeset for help on using the changeset viewer.