Convert ‘ASCII’ character to ‘Normal’ character

Please note that iconv(‘UTF-8’, ‘ASCII//TRANSLIT’, …) doesn’t work properly when locale category LC_CTYPE is set to C or POSIX. You must choose another locale otherwise all non-ASCII characters will be replaced with question marks. This is at least true with glibc 2.5.

iconv(‘UTF-8’, ‘ASCII//TRANSLIT’, “Žluťoučký kůň\n”);
// ?lu?ou?k? k??

setlocale(LC_CTYPE, ‘cs_CZ’);
iconv(‘UTF-8’, ‘ASCII//TRANSLIT’, “Žluťoučký kůň\n”);
// Zlutoucky kun

create canonical page link using WPPaginate class in wordpress

* Author: Yogesh Nayi
* Description: create canonical page link using WPPaginate class in wordpress.
if ( !class_exists( ‘CreateCanonical’ ) ) {

class CreateCanonical extends WPPaginate {

public function canonical_page_url() {
if ($this->type === ‘comments’ && !get_option(‘page_comments’))

$r = wp_parse_args($args, $this->options);
extract($r, EXTR_SKIP);

if (!isset($page) && !isset($pages)) {
global $wp_query;

if ($this->type === ‘posts’) {
$page = get_query_var(‘paged’);
$posts_per_page = intval(get_query_var(‘posts_per_page’));
$pages = intval(ceil($wp_query->found_posts / $posts_per_page));
else {
$page = get_query_var(‘cpage’);
$comments_per_page = get_option(‘comments_per_page’);
$pages = get_comment_pages_count();
$page = !empty($page) ? intval($page) : 1;

$prevlink = ($this->type === ‘posts’)
? esc_url(get_pagenum_link($page – 1))
: get_comments_pagenum_link($page – 1);
$nextlink = ($this->type === ‘posts’)
? esc_url(get_pagenum_link($page + 1))
: get_comments_pagenum_link($page + 1);

$prev = ”;
$next = ”;
$str = ”;
if ($pages > 1) {
if ($page > 1 && !empty($previouspage)) {
$prev = “<link rel=’prev’ href='{$prevlink}’>”;
if ($page < $pages && !empty($nextpage)) {
$next = “<link rel=’next’ href='{$nextlink}’>”;

echo $str = $prev . $next;

}//CreateCanonical end

global $CreateCanonical;
$CreateCanonical = new CreateCanonical();

Note : WPPaginate class is  a pagination class, so when to use pagination plugin is working as well fine.
Refer link (

check on post or page in attachment exist

* Author: Yogesh Nayi
* Description: this function used to check on post or page in attachment exist.
function check_is_attachments_exist(){
global $post;
$attachments = get_children( array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’) );

if ( $attachments ) {
if ( have_posts() ) : while ( have_posts() ) : the_post();

$args = array(
‘post_type’ => ‘attachment’,
‘numberposts’ => -1,
‘post_status’ => null,
‘post_parent’ => $post->ID

$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo wp_get_attachment_image( $attachment->ID, ‘full’ );
echo apply_filters( ‘the_title’, $attachment->post_title );
endwhile; endif;

echo “No-attachments-image”;

Diffrent between MySQL & NoSQL

First of all MySQL is a Relational Database product using SQL from Oracle while noSQL is not a product. It’s a (set of) type(s) of “products” or better phrase as a concept. As the name suggests it’s not SQL. NoSQL types and products are for example:

  • key-value stores like Redis, Tokio Cabinet or even Memcache can be mentioned
  • document database like MongoDb and CouchDB
  • graph databases like OrientDB
  • columnar datastores like Hadoop, Cassandra or Bigtable

SQL means Structured Query Language and this is related to how the data can be retrieved. This is not equivalent with Relational Databases. You can find noSQL RDBMS products as well.

Let me put it this way SQL is a language which can be used for data retrieval in relational databases (for example: MySQL, Postgres, Oracle) just like it can be used (however rarely used) in other types of databases/datastores.

What is NoSQL, and why do you need it?

  • NoSQL is a whole new way of thinking about a database. Though NoSQL is not a relational database, the reality is that a relational database model may not be the best solution for all situations.
  • NoSQL is a whole new way of thinking about a database. NoSQL is not a relational database. The reality is that a relational database model may not be the best solution for all situations. The easiest way to think of NoSQL, is that of a database which does not adhering to the traditional relational database management system (RDMS) structure. Sometimes you will also see it revered to as ‘not only SQL’.
  • It is not built on tables and does not employ SQL to manipulate data. It also may not provide full ACID (atomicity, consistency, isolation, durability) guarantees, but still has a distributed and fault tolerant architecture.
  • The NoSQL taxonomy supports key-value stores, document store, BigTable, and graph databases.


  • Why NoSQL? It’s high performance with high availability, and offers rich query language and easy scalability.
  • Relational and NoSQL data models are very different. The relational model takes data and separates it into many interrelated tables that contain rows and columns. Tables reference each other through foreign keys that are stored in columns as well.  When looking up data, the desired information needs to be collected from many tables (often hundreds in today’s enterprise applications) and combined before it can be provided to the application. Similarly, when writing data, the write needs to be coordinated and performed on many tables.