Monthly Archives: April 2017

Main differences between INNODB and MYISAM

Good Morning to all…. 🙂
In MYSQL, the MyISAM and InnoDB are the most commonly used storage engine. Both these storage enginee have advantages and disadvantages depending on the specific application.

The main and important difference between InnoDB and MYISAM is : the MyISAM does not support the advanced transaction process, and InnoDB support advanced transaction process.

MyISAM does not support the advanced transaction process

MYISAM InnoDB
MyISAM does not support the advanced transaction process InnoDB support the advanced transaction process
It’s very easy to use InnoDB is very difficult to use
MyISAM can do only a table-level lock. InnoDB implements row-level.
FULLTEXT Search is supported. FULLTEXT Search indexes doesn’t support until v5.6.
The main mechanism used is the key cache. It only caches index pages from .MYI files. Implemented transactions, foreign keys and relationship constraints.
ACID( Automicity, Consistency, Isolation and Durability) properties is not supported. ACID Properties is supported.
Supported high level table compression. It has Buffer Pool to cache data and index pages.
To take backup of MYISAM table the mysqldump helps to this process. You can take backup of InnoDB tables using just a snapshot of the filesystem.
MyISAM data and indexes are separate. The index is compressed the memory usage on the corresponding increase a lot. InnoDB have index and data are closely tied but do not use compression because of it InnoDB is huge
MYISAM doesn’t support transaction processing and foreign keys InnoDB support transaction processing and foreign keys
MyISAM can set up join index and other fields together. In the part of index, the InnoDB table have AUTO_INCREMENT field.
MYISAM depends upon file system block cache for storing reads in rows and indexes. InnoDB does caching inside the enginee, merging the row caches along with the index caches.
Indexes are stored in one file and datas are stored in another file. Both data and indexes are stored in a single file
COUNT(*) performance is very fast. COUNT(*) performance is very slow
It requires less system resources It requires more system resources like RAM.
MYISAM is generally rapid due to its simple construction and hence cost less in terms of server sources. The InnoDB is generally slower than MYISAM.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

How to remove null values from array in PHP

Hi all,
Today we study how to remove null values from an array.Its very important, to display all array values after removing NULL values in php code. If you have an array with NULL values but if you want to remove the NULL values from that array without loop. In PHP array_filter function helps to remove all null values from array.

Example1

$example1 = array(100, "Priya", null, "Varghese", NULL, "", 77);
 
$result1 = array_filter($example1, function($value) {
			  return !is_null($value);
			});
print_r($result1);

The Output as follows:

Array
(
[0] => 100
[1] => Priya
[3] => Varghese
[5] =>
[6] => 77
)

Example 2:

$myArray = array( 0, 'Apple', '', 'Orange' );
print_r( array_filter( $myArray ) );

The output as follows:

Array
(
[1] => ‘Apple’
[3] => ‘Orange’
)
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Insert Image Into Database and folder in AngularJS, PHP, MYSQL

Good Afternoon…
I got a query from my blog viewer How to upload images in database by using PHP and angularjs. He tried a lot of time but he can’t upload. Based on this request I try to solve this problem I can find the solution. And here I explain how to solve this situation with full code.

AngularJs is very helpful in web application. We can develope the application using angularjs with the help of php and mysql database.Angularjs can communicate to server to insert or fetch the data from database. The previous article describe how to insert the data to database, fetch the data, update the data, delete the data. In this article describe only how to insert the image file into database and specified folder using angularjs, mysql and php.

mainpage.php




  AngularJS PHP- upload and display image using FileReader with example
  
   



    
    
    

From the above code we can clearly say that, there are two part header part and body part. In header/head tag we specify the angularjs operations and angularjs library. In body part is the design part, in here we specified input tag as file because we upload the file like image.

file_insert_action.php


From the above code, variable conn is used for database connection. From there the angularjsoperation is the databasename

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

MYSQL Data Types

In here I explain the types of MYSQL data types. There are many possible types of datas are available in php with which the PHP variable may be initialized. Similarly MYSQL support several datatypes.

The database table contains multiple columns with attributes or with data types such as string or numbers or numberic. MYSQL provides different data types. Each daya type in MYSQL can be determined buy the following characteristics:

  • The space that takes up and whether the values is a fixed-length or variable length.
  • The kind of values it represents.
  • How MySQL compares the values of a specific data type.
  • The values of the data type can be indexed or not.

A datatype specifies particular types of data such as integer, boolean, float etc. A data types also specifies the possible values for that types, the operations can be performed on that type and MySQL supported data types that are huge in number, it separated into three category. They are,

  1. Numeric Data Type
  2. String Data Type
  3. Date and Time Data Type

Numeric Data Type

All standard SQL numeric data types supports in MYSQL. Createing MYSQL table with numeric data attribute, then this attibutes accepts only unsigned and signed numbers. The following list shows the common numeric data types and their descriptions:

Numeric Types Description
INT A standard integer data type it can be signed or unsigned. Basically it’s a normal sized integer . If signed, the allowable range is from -2147483648 to 2147483647. If unsigned, the allowable range is from 0 to 4294967295.

TINYINT It’s a very small integer data type in numeric. It can be signed or unsigned. If signed, the allowable range between -128 to 127. If unsigned, the allowable range between 0 to 255.
SMALLINT It’s a small integer data types in numeric. Signed values range from -32768 to 32767. Unsigned values range from 0 to 65535.
MEDIUMINT It’s a medium sized integer data type in numeric. It can be signed or unsigned. If signed, the allowable range is from -8388608 to 8388607. If unsigned, the allowable range is from 0 to 16777215.
BIGINT A large integer. If signed, the allowable range is from -9223372036854775808 to 9223372036854775807. If unsigned, the allowable range is from 0 to 18446744073709551615.
FLOAT(M,D) A single-precision floating point number. A floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D).
DOUBLE(M,D) It’s a double-precision floating point number in numeric data types. It support only signed numbers.

DECIMAL(M,D) It’s a fixed-point number in numeric data types. And it’s unpacked floating-point number that cannot be unsigned. NUMERIC is a synonym for DECIMAL.

String Data Type

In MYSQL, it support several string data type like CHAR, TEXT, VARCHAR etc.

Data Type Description
CHAR CHAR holds fixed length string betweeen 1 and 255 characters in length (for example CHAR(6)).
VARCHAR A variable-length string between 1 and 255 characters in length; for example VARCHAR(25).
BLOB / TEXT A field with a maximum length of 65535 characters. BLOBs are “Binary Large Objects” and are used to store large amounts of binary data, such as images or other types of files. Fields defined as TEXT also hold large amounts of data; the difference between the two is that sorts and comparisons on stored data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You do not specify a length with BLOB or TEXT.
BINARY / VARBINARY Both are differed with the fixed and variable length order of binary strings instead of the character string and has no character set like BLOB.
ENUM / SET NUM typed attribute will accept values which are limited with the given set of values. And, SET can have an entire set of values as a whole.

Date and Time Types

The data and time mysql data types are provided for representing temporal data that are used for MySQL date/time manipulation.

Data Types Description
DATE This displayed as ‘YYYY-MM-DD’. It’s between 1000-01-01 and 9999-12-31. It accept the data value.
DATETIME Displayed as ‘YYYY-MM-DD HH:MM:SS’. It’s between 1000-01-01 00:00:00 and 9999-12-31 23:59:59.
TIMESTAMP(m) Displayed as ‘YYYY-MM-DD HH:MM:SS’.
TIME Displayed as ‘HH:MM:SS’.
YEAR[(m] Default is 4 digits. Stores a year in 4-digit or 2-digit format.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

How to Increase the Maximum File Upload Size in WordPress

In your wordpress, the image is large or uncompressed then the site is too slow. In webdevelopment, many users have no knowledge regarding how to resize the image using image editing software. So, every one simply upload images as-is.Even if the image is resized by the theme to fit the width of the content area, it still requires time to process when loading the page. You have to simply upload the files and then to keep your site active and pretty.

Basically, there are three ways to upload files in WordPress:

  1. Connect to your server via an FTP client like FileZilla.
  2. Log in to your hosting provider by accessing their online file manager.
  3. Upload your media, themes, or plugin files directly from the WordPress Dashboard.

If you want to upload anything other than media,plugins or themes, you can always upload them via a file manager.

In wordpress dashboard, we can upload the images or media files through this platform. After login wordpress dashboard, select media link from left side and click add new and select the media from your computeryou can just drag and drop it in the box. And also maximum upload file size specified here. Here’s a screenshot:

From the screenshot we can say that, the maximum upload size is 24MB. We can change these upload size using different ways. There are three settings within the PHP info file that are relevant to your upload limit. You can search through the file to see what they are currently set to.

  • memory_limit – This defines how much memory is allocated to PHP. You will simply need to ensure that this number is as high or higher than the upload limit you want to set.
  • post_max_size – This defines the maximum size that is handled in a POST request. We will need to set this to our new upload limit.
  • upload_max_filesize – This defines the maximum size for file uploads. This will also be set to our new upload limit.

Increasing The WordPress Maximum Upload File Size

There are three basic ways you can go about solving this issue.

1: Theme Functions File

We can change the maximum file upload file using function file from wordpress theme folder. Select active theme from wp-content->theme folder. From here select the functions.php and add the below code into functions.php file.

@ini_set( 'upload_max_size' , '65M' );
@ini_set( 'post_max_size', '65M');
@ini_set( 'max_execution_time', '300' );

2. Create or Edit an existing PHP.INI file

In most cases if you are on a shared host, you will not see a php.ini file in your directory. If you do not see one, then create a file called php.ini and upload it in the root folder. In that file add the following code:

upload_max_filesize = 65M
post_max_size = 65M
max_execution_time = 300

3. htaccess Method

Somebody tried to change the uploaded file size through .htaccess file. Open or create the .htaccess file in the root folder and add the following code:

php_value upload_max_filesize 65M
php_value post_max_size 65M
php_value max_execution_time 300
php_value max_input_time 300

There are three basic ways you can go about solving this issue. I will start with the two easiest ones, then move on to changing the server settings yourself – there are a number of options here as well.

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.