Format specifiers for DB Column

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mediatagging
Forum Newbie
Posts: 3
Joined: Wed Nov 11, 2009 1:53 am

Format specifiers for DB Column

Post by mediatagging »

I am breaking down the wordpress application and trying to understand what exactly does %s and %d mean. I have an idea from AS3 but wanted to make sure.

The exampe in the wordpress document is below

Code: Select all

/**
 * Format specifiers for DB columns. Columns not listed here default to %s.
 * @since 2.8.0
 * @see wpdb:$field_types
 * @see wpdb:prepare()
 * @see wpdb:insert()
 * @see wpdb:update()
 */
$wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
    'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d');
 
 
Thanks.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Format specifiers for DB Column

Post by flying_circus »

I have not used wordpress, so this is clearly speculation:

I would assume it is making a call to a function like (s)printf in that %s denotes the datatype as a string and %d is decimal.

PHP function: sprintf
Post Reply