MySQL Foreign Keys

A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another table.
The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table.

* If you want to use foreign key all your tables should be with InnoDB engine.

Foreign Key on create table

CREATE TABLE Orders (
    OrderID int NOT NULL,
    OrderNumber int NOT NULL,
    PersonID int,
    PRIMARY KEY (OrderID),
    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
);

Continue reading “MySQL Foreign Keys” »

Setup Linux Ubuntu For Web Development

Install Node.js

sudo apt-get install curl

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

sudo apt-get install -y nodejs

Install LAMP stack

sudo apt-get install apache2

sudo apt-get install php7.0 libapache2-mod-php7.0

sudo apt-get install mysql-server

sudo /etc/init.d/apache2 restart

Install phpmyadmin

sudo apt-get install phpmyadmin

sudo nano /etc/php/7.0/apache2/php.ini

Uncomment extension=msql.so

sudo /etc/init.d/apache2 restart
sudo nano /etc/apache2/apache2.conf 

At the bottom of the file write:

Include /etc/phpmyadmin/apache.conf

Save it and then:

sudo /etc/init.d/apache2 restart

Install Filezilla

sudo apt-get install filezilla

Install Gimp

sudo add-apt-repository ppa:otto-kesselgulasch/gimp

sudo apt-get update

sudo apt-get install gimp

Install Chrome

wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list

sudo apt-get update 
sudo apt-get install google-chrome-stable

Install PhpStorm

Download linux version from https://www.jetbrains.com/phpstorm/download/

sudo tar xf PhpStorm-*.tar.gz -C /opt/

cd /opt/PhpStorm-*/bin

./phpstorm.sh
License server: http://www.aku.vn/idea

Linux basic commands

pwd -> show the current working directory
ls -a -> show list of all files and folders (hidden also)
ls -l -> show list of all files and folders with their permissions

mkdir -> Make directory
rmdir -> Delete directory
rm -R -> Delete directory even if it is not empty

cd -> moves back to your home directory
cd .. -> moves back one directory
cd / -> moves to root directory of linux
cd ~ -> moves to home directory

touch file.txt -> create file
nano file.txt -> edit file with nano-editor
cat file.txt -> show the contents of a file
less file.txt -> show the contents of a file with scroll
mv file.txt new.txt -> rename filename
cp file.txt new.txt -> copy file
rm file.txt -> delete file
chmod -> is used to change the permissions of files or directories (example “chmod 754 myfile”)

which -> shows program or folder location
history -> show last 500 commands

ifconfig -> network info
iwconfig -> wireless info

top -> shows the top processes based on certain criterias like cpu usage or memory usage
df -> disk space

sudo apt-get install “program-name” -> install program
sudo apt-get remove “program-name” -> delete program
sudo apt-get update -> update all packages
sudo shutdown -h -> shutdown system (halt)
sudo shutdown -r -> restart system

CodeIgniter Session Error – Operation not Permitted

On some hostings you can receive this error.

A PHP Error was encountered

Severity: Warning

Message: unlink(/tmp/ci_session0189a7f1c86eb18fb70afcfedc2d5040e9c23146): Operation not permitted

Filename: drivers/Session_files_driver.php

To fix this go to application > config > config.php and edit this line:

$config['sess_save_path'] =  BASEPATH . 'cache/';

Laravel first steps

Hello, this article is for beginners and will show basic functions.

Installation of Laravel

To begin with instalation we need composer. In console write the following.

composer create-project --prefer-dist laravel/laravel NameOfTheProject

What is artisan

Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.

Continue reading “Laravel first steps” »