Oct
18

Insert update and delete in WordPress.

In the core php, we need to write at-least 10 to 15 lines, sometimes more than that for the database connection and insert update or delete operations on the database..

But in the wordpress we just need a single line for the opration and no need to connect to database. Because this steps are done at the installation only.

INSERT QUERY :

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

table (string):

The name of the table.

data (array):

Data to insert in column => value pairs.

format (array|string) : (optional)

An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types.

 

UPDATE QUERY :

$wpdb->update( $table, $data, $where, $format = null, $where_format = null );

table (string) :

The name of the table to update.

data (array) :

Data to update in column => value pairs.

where (array) :

A named array of WHERE clauses in column => value pairs. Multiple clauses will be joined with ANDs.

format (array|string) :(optional)

An array of formats to be mapped to each of the values in $data. If string, that format will be used for all of the values in $data.

where_format (array|string) : (optional)

An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where.

Possible format values:

%s as string; %d as decimal number and %f as float. If omitted, all values will be strings.

 

DELETE QUERY :

$wpdb->query(‘query’);

query (string) :

The SQL query you wish to execute for deletion.

 

Its really very easy to play with database in the WordPress.

Start to do that and enjoy coding.

 

Arpi

hiii friends… i am doing msc in computer application and information technology. we are here to share our knowledge and idea on shareprogrammingtips.com.

More PostsWebsite

You may like to read this also....

1 Comment to “Insert update and delete in WordPress.”

  • Arjun Singh Chauhan January 25, 2013 at 4:35 am

    Hi,i am new to wordpress,unable to connect the form to the database,how to use the functions???????????? Please help….

Post comment

*

CommentLuv badge
Follow us on Twitter! Follow us on Twitter!

Search in this website

our sponsors

latest comments

Find us on Facebook

Top Authors

35 posts
saurabh
22 posts
10 posts

Find us on stackoverflow

Polls

Tell us who you are

View Results

Loading ... Loading ...

My Bookmarks

Sponsers Link