Skip to main content


Showing posts from October, 2011

PHP Reference Sheet (Basics)

Data Types integer, float, boolean, string, array, object, resource, NULL Variable Declarations $variablename = <value>; $anothervariable =& $variablename; (Assign by Reference) Declare Array $arrayname = array(); Initialize Array $arrayname = array(<value1>, <value2>, <value3>); $arrayname = array(<key> => <value>, <key> => <value>); (Define Keys) $multiarray = array(<key> => array(<value1>,<value2>)); (Multi-dimensional) Common Array Functions sort(<array>); (Sort array assigns new keys) asort(<array>); (Sort array maintain keys) rsort(<array>); (Sort array in reverse, new keys) arsort(<array>); (Sort array in reverse, maintain keys) count(<array>); (Count elements) count(<array>,COUNT_RECURSIVE); (Count multidimensional array) array_push(<array>,<value>); (Push item onto end of array) array_pop(<array>


Last week, when using the GROUP_CONCAT() function on a MySQL database, I got an unexpected result. :( Indeed, instead of getting my result as VARCHAR types, I got it as BLOB types! For information, a BLOB is a binary large object that can hold a variable amount of data: Because BLOB values are treated as binary strings, it is not easy to use. This is why we would prefer to have VARCHAR values. So the question is how to get around this frustrating problem? The answer is, for once, very simple! :D You simply need to: Open your my.ini or my.cnf file; Change the value of the group_concat_max_len system variable to 512 (no ‘k’ suffix); Restart the mysql service To verify if the value has been successfully updated, execute the following command in your mysql client: mysql> show variables like "%concat%"; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | group_

Different type of Cookies?

What are Temporary Cookies? Temporary , or session , cookies are removed from your computer after you close the browser. Websites use them to store temporary information, such as items in your shopping cart.   What are Persistent Cookies? Persistent , or saved , cookies remain on your computer after you close the browser. Websites use them to store information, such as your sign-in name and password, so that you don't have to sign in each time you go to a particular site. Persistent cookies can remain on your computer for days, months, or even years. What are First-party Cookies? First-party cookies come from the website that you're viewing and can be either persistent or temporary. Websites might use these cookies to store information that they'll reuse the next time you go to that site. What are Third-party Cookies? Third-party cookies come from other websites' advertisements (such as pop-up or banner ads) on the website that you're

Cloud Computing vs. Virtualization

Cloud computing and virtualization are both technologies that were developed to maximize the use of computing resources while reducing the cost of those resources. They are also mentioned frequently when discussing high availability and redundancy. While it is not uncommon to hear people discuss them interchangeably; they are very different approaches to solving the problem of maximizing the use of available resources. They differ in many ways and that also leads to some important considerations when selecting between the two. Virtualization: More Servers on the Same Hardware Virtualization It used to be that if you needed more computing power for an application, you had to purchase additional hardware. Redundancy systems were based on having duplicate hardware sitting in standby mode in case something should fail. The problem was that as CPUs grew more powerful and had more than one core, a lot of computing resources were going unused. This obviously cost companies a great d

Connection between PHP (server) and Android (client)

Nowadays, PHP and Android are widely used platforms, while PHP is used for dynamic web development, Android is an OS for mobiles, tablets etc. To develop Android applications we can use the benefits of PHP to communicate it with MySQL database and get required data from there. We can use JSON and HTTP as an intermediate of communication between Android and PHP. The whole process can be divided into five steps: 1)       An HTTP request is sent from Android(Client) to PHP(Server). 2)       PHP runs it’s script to make connection with database, and send request to MySQL database for required data. 3)       MySQL responds back to PHP with requested data. 4)       PHP script analyse the date and coverts it into information. The whole information is then converted into JSON format and sent to the Android (Client). 5)       Android script reads the data, perform its operations and shows it on it’s screen. The Whole process has also been described in the following

Overloading in PHP

PHP's interpretation of "overloading" is different than most object oriented languages. Overloading traditionally provides the ability to have multiple methods with the same name but different quantities and types of arguments. In PHP it's achieved through magic methods. Remember : 1) All overloading methods must be defined as public. 2) None of the arguments of these magic methods can be passed by reference. In PHP we have following two types of overloading and their respective functions. Property Overloading : Property overloading is achieved through __get(), __set(), __isset() and __unset() funtions. Property overloading only works in object context. These magic methods will not be triggered in static context. Therefore these methods should not be declared static. <?php require_once "DB.php"; class Persistable {        private $data = array();     private $table = "users";        public function __construct($user) {            

Explain ACID

The ACID model is one of the oldest and most important concepts of database theory. It sets forward four goals that every database management system must strive to achieve: atomicity, consistency, isolation and durability. No database that fails to meet any of these four goals can be considered reliable. Let’s take a moment to examine each one of these characteristics in detail: Atomicity : states that database modifications must follow an “all or nothing” rule. Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. It is critical that the database management system maintain the atomic nature of transactions in spite of any DBMS, operating system or hardware failure. Consistency : states that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a s

MySQL Basics

What Is MySQL : MySQL is a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server. It’s the most popular Open Source SQL database, provided by MySQL AB. MySQL AB is a commercial company that builds is business providing services around the MySQL database. mysql vs mysqli        :         mysqli is the object-oriented version of mysql library functions. Default Port             :        3306 Storage Engines      :        MyISAM, InnoDB, BDB(BerkeleyDB), MEMORY, CSV, BLACKHOLE  etc.. The following table describes the maximum length for each type of identifier. Identifier Maximum Length (characters) Database Name 64 Table Name 64 Column Name 64 Index Name 64 Stored Function or Procedure 64 Trigger Name 64 View Name 64 Alias 255 Advantages o