Boilerplate WordPress Plugin Development Tutorials #9 Understand & Use $wpdb Global Object WordPress

In this video we’ll see:

Boilerplate WordPress Plugin Development Tutorials #9 Understand & Use $wpdb Global Object WordPress

SOME BASIC IDEA ABOUT $wpdb OBJECT AND ITS CLASS FILE
===========================================================

For performing database operations WordPress provides a class wpdb which is present in the
file – wp-includeswp-db.php. This class abstracts the database functions for WordPress
and most WordPress functions directly or indirectly use this class.We can create an object
of this class to perform database operations but WordPress creates an object of this class
during the load of WordPress.

This object is $wpdb and is a global object. So in case we want to perform any database
operation we should use this global $wpdb object and call functions on them.

By the help of $wpdb Object we can perform all types of operations like in CRUD

SYNTAX TO USE GLOBAL $wpdb OBJECT
==========================================

function my_function() {

global $wpdb;

//………………

//Some Operation on database using $wpdb

//………………

}

Get Data from Database
========================================
There are a lot of functions on $wpdb to fetches values from the database. Some of these
functions are specialized to get one value, one row or one column from the database table.

1. get_var()
========================
The get_var function takes in a query and returns one value which can be directly
assigned to a variable.

2. get_row
========================
This method is useful to get a complete row from a query. This method takes in a query
and also takes a parameter to indicate in which format the output should be.

The first parameter to get_row is a query and the second parameter can be one of the
following values

OBJECT ( this is the default value ) – In this case the object is an objects with the
columns of the table as the members of the object.
ARRAY_A – In this case the result is returned in for of an associative array.
ARRAY_N – in this case the result is in for of an numerically indexed array.

3. get_col
========================
This method is useful to get one column from a query. The output of this function is
an array.

4. get_results
========================
This method is used to get an output of a generic query which has output as multiple
rows and multiple columns. The default output for this function is array of objects in
which each object represents one row of the result.

SOCIAL :
===============
Subscribe : https://www.youtube.com/owthub
FACEBOOK : https://www.facebook.com/owthub
TWITTER: https://twitter.com/owthub
BLOG: https://onlinewebtutorhub.blogspot.in/
UDEMY: https://www.udemy.com/user/online-web-tutor

Other Tutorials
===============
Wordpress Customizations:
———————————
Wordpress Theme (Hindi): https://goo.gl/MZ8maF
Wordpress Widget (Hindi): https://goo.gl/Dc2htn
Wordpress Plugin (English): https://goo.gl/BA7dYG
Wordpress Theme Options (English): https://goo.gl/Vjv3Ub
Wordpress JSON Rest API (English): https://goo.gl/SVQRQR
Wordpress JSON Rest API (Hindi): https://goo.gl/NNWfKa
and many more…

Javascript framework:
———————————-
Learn backbone.js here! (English) : https://goo.gl/Qd2Pcs
Learn Vue JS here ! (Hindi): https://goo.gl/MVtsmh

PHP Frameworks:
———————————-
Laravel tutorial (Hindi): https://goo.gl/Nh9qJk
CakePHP tutorial (Hindi): https://goo.gl/uRsS3G

Tags:
———————————-
Wordpress Plugin Development using boilerplate tutorial for beginners step by step,
Wordpress Plugin Development using boilerplate tutorial,
Wordpress Plugin Development using boilerplate tutorial in hindi,
Wordpress Plugin Development using boilerplate,
Wordpress Plugin Development using boilerplate for beginners,
Wordpress Plugin Development using boilerplate tutorial for beginners,
Wordpress Plugin Development using boilerplate tutorial for beginners,
Wordpress Plugin Development using boilerplate tutorials guide,
learn WordPress Plugin Development using boilerplate framework step by step,
learn WordPress Plugin Development using boilerplate from scratch,
Developing Plugins With WordPress Boilerplates: Building a Plugin,
WordPress Plugin Boilerplate,
WordPress Plugin Development for Beginners: Developing a Plugin,
Get started with the WordPress Plugin Boilerplate,
The WordPress Plugin Boilerplate,
online web tutor,
profotech solutions,

Thanks
Online Web Tutor
Keep learning and Sharing 🙂

Post Author: hatefull