Book Image

WordPress Web Application Development

By : Rakhitha Nimesh Ratnayake
Book Image

WordPress Web Application Development

By: Rakhitha Nimesh Ratnayake

Overview of this book

Table of Contents (19 chapters)
WordPress Web Application Development Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Querying the database


As with most frameworks, WordPress provides a built-in interface for interacting with the database. Most of the database operations will be handled by the wpdb class located inside the wp-includes directory. The wpdb class will be available inside your plugins and themes as a global variable and provides access to all the tables inside the WordPress database, including custom tables.

Note

Using the wpdb class for CRUD operations is straightforward with its built-in methods. A complete guide for using the wpdb class can be found at http://codex.wordpress.org/Class_Reference/wpdb.

Querying the existing tables

WordPress provides well-optimized built-in methods for accessing the existing database tables. Therefore, accessing these tables becomes straightforward. Let's see how basic CRUD (Create, Read, Update, Delete) operations are executed on existing tables.

Inserting records

All the existing tables contain a prebuilt insert method for creating new records. The following list...