List foreign keys in mysql

information_schema The following query will list out the foreign keys in mysql. It finds it out from the information_schema database. select concat(table_name, '.', column_name) as 'foreign key', concat(referenced_table_name, '.', referenced_column_name) as 'references' from information_schema.key_column_usage where referenced_table_name is not null; The output is a clean table listing out all foreign keys ...

Create foreign key using Phpmyadmin

The innodb storage engine supports foreign keys in Mysql. To create foreign keys in phpmyadmin : 1. Convert both tables into innodb, if they are not already. 2. View the structure of the table which will have a foreign key. Make the referencing field an INDEX. 3. Now come back to structure view and click Relation view. In the Relation view page the field (which ...

Import mysql dump files with view definer and sql security

Views and mysqldump A little back I tried to backup a database from my webhost and restore it on my localhost mysql. It had a few views. The import of the sql file seemed to work fine. But on accessing the views in phpmyadmin mysql gave the error : #1449 - There is no 'projects'@'localhost' registered The problem is with a security feature ...

Enable unicode utf-8 characters in wordpress blog title

Wordpress and unicode Sometime back I was trying to put unicode characters(utf-8) in the title of a blog from wp-admin > settings > general. After saving it became like ?????????. All pages had utf-8 in their meta tags so the issue was somewhere else. A working solution was found : 1. Go to phpmyadmin and select the database of this blog 2. Select table ...

Open View MS Access mdb files in Ubuntu Linux

MDB Tools MDB Tools is a set of utilities that can be used to read mdb format (Microsoft Access) database files on Linux. It also comes with a gtk based graphical frontend tool called Gmdb (Gnome MDB Viewer) that can be used to read the table structure and data quickly and easily. More information can be found at the project website http://mdbtools.sourceforge.net/. On ...

Create AutoIncrement column/field in Apache Derby

While creating a table a particular column / field can be made autoincrement as : CREATE TABLE students ( id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), name VARCHAR(24) NOT NULL, address VARCHAR(1024), CONSTRAINT primary_key PRIMARY KEY (id) ) ; The value of an autoincrement column increments automatically with every insert and doesnt need to be specified in the insert command. It ...

PHP redirect – go back to previous page

To go back to the previous page the superglobal variable $_SERVER can be used. $_SERVER has the link to the previous page. So to redirect simply : #Method to go to previous page function goback() { header("Location: {$_SERVER}"); exit; } goback(); ...

PHP Format numbers to Indian Numerical System

The numerical system used in India differs from the Western system in terms of the placement of the thousands separator. Example : Number -> 1000000 Indian System -> 10,00,000 (Ten Lakh) Western System -> 1,000,000 (1 Million) While echoing numbers in PHP it is possible to format numbers with such separators using functions like number_format. To format a number in the Indian Numerical System ...

Create short links using bit.ly from php

bit.ly is a simple url shortner which has an api , which can be called from within php to shorten links. Code : function get_short_url($url) { $bitly_login = "your_login_name"; $bitly_apikey = "your_api_key"; $api_call = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$bitly_login."&apiKey=".$bitly_apikey); $bitlyinfo=json_decode(utf8_encode($api_call),true); if ($bitlyinfo == 0) { return $bitlyinfo; } else { return false; } } The above function can be used to shorten a big url , as : if ($shortlink = get_short_url("http://www.google.com/")) { echo $shortlink; } ...

Create deb file from source using checkinstall on ubuntu

Many software applications for linux are available in the form of source code which needs to be compiled. The general process to compile such software is by running the configure, make and make install commands. After the install process the files get installed in the system directories and the software can be run from the shortcuts or terminal command. However there ...



Connect with us