Just Start Typing Text and Press Enter

alt text
PANKAJ SINGH
Web Designer & Developer

DRINK A COFFEE WITH ME TODAY

Loading...
Message Snet
Error!

Blog posts

Menu
Close
Apr 17, 2016

Inserting data Into The Database in wordpress

0 Comment | By
Inserting Into The Database

 

// This is the format for inserting data into database in wordpress

$wpdb->insert( $table, $data, $format);

 

<?php

   $wpdb->insert($wpdb->usermeta, array(“user_id” => 1, “meta_key” => “awesome_factor”, “meta_value” => 10), array(“%d”, %s”, “%d”));

 

  // Equivalent to:

// INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (1, “awesome_factor”, 10);

?>

The three values you can use are %s for strings, %d for decimal numbers and %f for floats.

Leave A Comment

Author Details

My name is Pankaj Singh and I am a web designer and developer with over 3+ years of professional experience in the design industry, currently living in New Delhi, India. I have a Master of Computer Application from GGSIPU University, and my primary focus and inspiration for studies is Web Development.

Share Post