Skip to main content

Posts

Showing posts from October, 2014

Difference between empty, null & isset

1. Null A variable is considered to be null if: it has been assigned the constant NULL. it has been unset(). it has not been set to any value yet. Note : empty array is converted to null by non-strict equal '==' comparison. Use is_null() or '===' if there is possible of getting empty array. eg: 1 $a = array(); $a == null  <== return true $a === null < == return false is_null($a) <== return false eg: 2 Note the following: $test =''; if (isset($test)){     echo 'Variable test exists'; } if (empty($test)){ // same result as $test = ''     echo ' and is_empty'; } if ($test == null){ // not the same result as is_null($test)     echo 'and is_null'; } The result would be: Variable test exists and is_empty and is_null eg : 3 But for the following code...: $test =''; if (isset($test)){     echo 'Variable test exists'; } if (empty($test)){ // same result as $test =

MySql query used in projects

Mysql Query Helps you in Project 1. Copy data of one table to another  CREATE TABLE student2 SELECT * FROM student;     or CREATE TABLE student2 LIKE student; INSERT student2 SELECT * FROM student; 2. Copy structure of one table onto another but not data  CREATE TABLE student2 SELECT * FROM student WHERE 1=0 3. Insert data into table form another table on id basis   INSERT INTO student2 SELECT * FROM student WHERE id = 2; 4. Update the record in table Update students set first_name=’Sudhir’ where id=2; 5. Create table query CREATE TABLE IF NOT EXISTS `cities` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `country_id` int(10) unsigned DEFAULT NULL, `state_id` int(10) unsigned DEFAULT NULL, `name` varchar(100) NOT NULL DEFAULT '', `created` datetime DEFAULT NULL, `modified` datetime DEFAULT NULL, PRIMARY KEY (`id`), KEY `name` (`name`), KEY `country_id` (`country_id`) ) ENGINE=InnoDB 6. Delete Command DELETE FROM contacts