Programming, WordPress

Get the list of year associated with the posts

WordPress has a global object variable $wpdb, which communicates with the WordPress database. We can read more about $wpdb in Codex.

To get the list of the year in the posts, you can do the following :

 

In the aforementioned code, if you wish to get the year associated with the custom post type update the post_type name with your custom post type.

 

Hits: 7

Standard
Programming

Importing a mysql database using command prompt in WAMP

Sometimes, you get an error while importing sql file. To import the database without any hassle in WAMP for windows, we can use the following command line

  1. Open the command line : Click Windows + r, type cmd and enter
  2.  Copy the mysql path from bin folder i.e. Copy path : D:\wamp64\bin\mysql\mysql5.7.11\bin\,  and set the same path in the command line
  3.  Run MySQL in command line i.e MySQL -u root -p
  4.  It will ask for MYSQL root password. Enter password ( if it is empty, simply press enter )
  5. To create a new database, run the following command line i.e CREATE DATABASE db_name . Replace db_name with the name of the database you want to create
  6.  To import the tables in the new or existing database, type the following in command : USE db_name;
  7.  Copy the path of the database from where you want to import the database. Enter the source for the db with command : SOURCE [path to sql]
    source folderPath\database_name.sql
  8. Finally Your tables are imported

Hits: 147

Standard