• Home
  • Technology
    • Ebullientech
    • Entrepreneurship
    • Video Technology
    • Cloud Computing
    • Business Analysis
  • Healthcare
    • Pharmacology
  • Thoughts
    • Food
    • General
    • Stories
    • Places
    • Workplace
    • Social Issues
    • Reviews
  • Quotes
  • Ebullientech News and Events
  • About

Kamalika's Notebook

thinking nothing...............!!

How To Get Posts Category In WordPress

April 30, 2015 By Kamalika Leave a Comment

Problem

Can we get the list of blog posts in the following structure?

Published Date
Author
Category
Post Title
Blog URL

Solution

[bash]

SELECT p.ID,DATE(p.post_date) Date,u.display_name Author,p.post_title Title,GROUP_CONCAT(t.name) Category,
CONCAT(‘http://yourdomain.com/blog/’,p.post_name) URL
FROM wp_posts p
LEFT JOIN wp_users u ON p.post_author = u.ID
LEFT JOIN wp_term_relationships rel ON rel.object_id = p.ID
LEFT JOIN wp_term_taxonomy tax ON (tax.term_taxonomy_id = rel.term_taxonomy_id AND tax.taxonomy=’category’)
LEFT JOIN wp_terms t ON (t.term_id = tax.term_id AND t.name!=’uncategorized’)
WHERE p.post_status = ‘publish’ and p.post_type=’post’
GROUP BY p.ID
ORDER BY Date;

[/bash]

Tables used in the above query are:

wp_posts

wp_posts table contains all kinds of contents of an WordPress Website / Blog and the content types include the following:

  • posts
  • pages
  • custom post types
  • attachments
  • links
  • navigation menu items (which are stored as individual posts)

wp_users

wp_users table contains user data.

wp_term_relationships

WordPress content types are attached to the following types of data:

  • categories
  • tags
  • custom taxonomies and terms
  • post metadata

wp_term_relationships contains the relationship between WordPress contents and categories / tags.

wp_term_taxonomy

wp_term_taxonomy contains the taxonomy details.

wp_terms

wp_terms contains the details of all defined categories and tags.

The WordPress Database Structure

WordPress uses a number of database tables with relationships between them, most of these relationships are one-to-many.

One-to-many relationships occur when each record in TableA may have many linked records in TableB but each record in TableB may have only one corresponding record in TableA.

In case of WordPress, one user can have many posts that they have written related to their user record.

The diagram below is taken from the WordPress Codex and shows the database tables and how they are related / linked:

WordPress Database Diagram

Filed Under: Ebullientech, MySQL, WordPress Tagged With: Custom WordPress Queries, Ebullientech, Ebullientech Interactive LLP, SQL Query, WordPress, WordPress Consultant Mumbai, WordPress Database Diagram, WordPress Database Structure, WordPress Developer Mumbai, WordPress SQL Query Category, WordPress to SQL Query Query

HTTP Status Codes

April 19, 2015 By Kamalika 4 Comments

What is Http?

As per Wikipedia definition… “The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web. Hypertext is structured text that uses logical links (hyperlinks) between nodes containing text.”

Whenever a request is made to a server for any page (webpage) of any website an HTTP status code is the response to the request. A request is made when a search engine crawler (like Googlebot) crawls the page or a user tried to open the page in a web browser.

This status code provides the information about status of the request. Some of the common status codes are:

  • 200 – The server successfully processed the request. Generally, this means that the server provided the requested page
  • 301 – The page is permanently moved
  • 404 – The requested page doesn’t exist
  • 500 – Internal server error

HTTP Status codes are always three-digit numbers. The first digit of status code begins with one of five numbers, 1 through 5. From the 100s through the 500s, status codes are divided into following categories:

  • 100s – Informational: Request has been received and the process is continuing
  • 200s – Success: Request was received and processed successfully
  • 300s – Redirection: Request has been received, but needs to perform an additional step to complete the request
  • 400s – Client Error: Request was made by the client, but the page is not valid
  • 500s – Server Error: Valid request was made by the client, but the server failed to complete the request

Below I have shared a few learning resources on HTTP Status Codes:

  • Wikipedia: http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
  • IETF: http://www.ietf.org/assignments/http-status-codes/http-status-codes.xml
  • W3C: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  • REST API: http://www.restapitutorial.com/httpstatuscodes.html

HTTP Status Code and PHP

PHP has a function http_response_code which gets or sets the HTTP Response / Status Code.

If you pass no parameters then http_response_code will get the current status code. If you pass a parameter it will set the response code.

[php]

<?php

http_response_code(404);

echo http_response_code();

?>

[/php]

The above code will first set the http status code to 404 and then print the current status code, i.e., 404.

Please note that this http_response_code was introduced in PHP 5.4.

Filed Under: Apache, HTTP, Technology Tagged With: Cloud Architect Mumbai India, http, http status codes, Tech Consultant Mumbai India

Install the PHP DOM Extension on CentOS

February 23, 2015 By Kamalika Leave a Comment

I was trying to import the sample data provided with a ThemeForest theme to my client’s WordPress website and failing. Initially I thought it’s a file permission issue but even after changing file permission to 0755 and eventually to 0777 didn’t improve the situation. Suddenly I realized file permission issue is sorted and the current issue is server not having PHP DOM installed!

What is DOM?

As per Wikipedia… “The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents.”

And as per w3.org… “The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page.” [Read more…]

Filed Under: CentOS, LAMP, PHP, Technology Tagged With: Document Object Model, DOM, How to add PHP DOMDocument extension, How to Check PHP DOM is Installed, PHP DOM Extension, PHP-XML, What is PHP DOM extension

PHP and MVC Design Pattern

February 11, 2015 By Kamalika Leave a Comment

The root cause of writing Software is simple Software solves problems. We analyze the requirements and break them into smaller problems (modules) and then write the solution for each such problem. Every line of code (LOC) we write is meant to resolve some problem. A pattern or design pattern defines how we solve problems, we must remember that a pattern is never the solution itself it is a way solution is written or developed or rather architected.

Around the world developers and solution architects are always excited about using MVC in fact the developer community often frowns upon those who don’t use it! I remember one of friends who once asked me… “OMG! You are not using any MVC of framework? Just writing native code?”… I tried hard to reason… “We may not be using MVC but we are using patterns and its pure OOP, I don’t think such application really requires MVC!”… “No… No… I think you must!”… I resigned!

What exactly MVC has to offer:

  • Reduced Code complexity
  • Code reusability
  • Increased flexibility
  • Decoupled code

Have we ever thought? MVC cannot solve the Code complexity or reusability or even flexibility problem, it’s the developers who can solve these problems. Writing decoupled code is also a developer’s thing; a pattern like MVC will create and environment with certain restrictions and rules but the code has to be written by a developer, the logic behind the code has to be thought out by a human! [Read more…]

Pages: 1 2 3

Filed Under: Ebullientech, PHP Tagged With: CodeIngiter, Ebullientech, Ebullientech Interactive LLP, Laravel, Model View Controller, PHP, PHP Frameworks, PHP MVC, Symphony, Zend Framework

PHP vs. Java which is a better Object Oriented Language?

February 9, 2015 By Kamalika Leave a Comment

I left Microsoft Technologies and shifted to Open Source around July 2006, that’s when I was first introduced to the LAMPP Stack (Linux Apache MySQL Perl PHP), though I started my journey with Perl but gradually moved towards PHP. Open Source Technologies and PHP have been my bread and butter since then, but I could never admire PHP like I admired C, C++ and Java, always felt limited even when I was applying OOP concepts with PHP but yes in spite of this I loved PHP arrays and the wide range of array functions. My first PHP OOP project happened in December 2007 where I got introduced to Zend Framework as well, since then I’m still in love with ZF but ironically still not fond of PHP, especially PHP OOP! PHP’s weaknesses as an OOP over Java repeatedly kept disturbing me, and this became my favorite interview question for any candidate who claimed to have PHP and Java OOP concepts. I would say about 25-30% of the people could hit chord somehow but rest failed miserably.

In the first section of this article I’ll discuss about the salient features of Object Oriented Programming, next section I’ll address the broad differences between PHP & Java, and in the final section I’ll try to lay down the key weaknesses of PHP OOP over Java.

Object Oriented Programming

Conventional or traditional programing using a high level programming language like C is termed as Procedure Oriented Programming where things happen sequentially, i.e., reading (input), computing, printing (output) take place in sequences. Functions or procedures are written to accomplish all kinds of computations, some functions are system defined and some are user defined.

Object oriented programming emphasizes more on data and data structures rather than functions or procedures; they are tied with the data on which they operate. Data is defined as objects and objects are supported by member functions which are part of the data structure. Object oriented programming takes a bottom-up approach in contrast with the top-down approach of procedure-oriented programming where small modules consisting of data and member functions unite to implement a large application. [Read more…]

Pages: 1 2 3

Filed Under: PHP Tagged With: Java OOP, Java versus PHP, Object Oriented Programming, PHP OOP

  • « Previous Page
  • 1
  • 2
  • 3
  • 4
  • 5
  • …
  • 10
  • Next Page »

Let’s connect…

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Hello There…

I'm Kamalika, a techpreneur & startup mentor, blogger, hobbyist photographer, Netflix & Kindle indulgent, food connoisseur, Starbucks aficionado and former Disney employee ...next

Looking for something?

Tags

All in One SEO Pack AWS Banaras Blogger Blogging Blogs Dasaswamedh Ghat Ebullientech Ebullientech Interactive LLP Facebook Facebook Developers father's day father's day wishes father's day wishes for dad fathers day love Fathers Day Special Fathers Day wishes from daughter Father’s day memories GeoTech GeoTech Informatics HipHop for PHP Kamalika Guha Roy Kashi Ganga LAMP MySQL Nabaneeta Guha Roy Online Marketing PayPal PayPal's suspension of Indian bank transactions PHP PHP & MySQL Saraswati Puja Search Engine Optimization SEO Startup The Ganges TypePad UCO HUT Varanasi Web 2.0 Web 2.0 Design Web Design Web Marketing WordPress WordPress.COM

Timeline

  • 2024 (1)
  • 2021 (3)
  • 2020 (7)
  • 2019 (4)
  • 2018 (1)
  • 2015 (6)
  • 2014 (13)
  • 2013 (9)
  • 2010 (7)
  • 2009 (2)

Topics

Copyright © 2021 · Kamalika Guha Roy, Powered by: Ebullientech