Question: How can PHP read the hash portion of the URL?
Answer: PHP can't read the hash portion of the URL
index.php?page=group#birthday
Here, PHP can not read the birthday
Question: What Is difference between array_combine and array_merge?
Answer:
array_combine give an array by combining two arrays($keyArray, $valueArray) and both $keyArray & $valueArray must have same number of elements. $keyArrays become keys of returning Array, $valueArray become values of returning Arrays.
array_merge gives an array by merging two array ($array1, $array2) and both can have different number of elements. $array1 and $array2 are added in returning array.
Question: What Is difference between Cookie and Session?
Answer:
Cookie are stored in client side (e.g Browser) where as Session are stored in server side (tmp file of web server). Cookie can be added/update/delete from browser but session can't delete from browser.
Session is depended on cookie. For example: When user login in website then session is created in webserver. To communicate the webserver with user, an cookie is created by the application. with use of this cookie-key, Server get to know that user is login OR not.
Question: What are encryption functions in PHP?
CRYPT(), MD5()
Question: How to store the uploaded file to the final location?move_uploaded_file( string filename, string destination)
Question: Explain mysql_error(). The mysql_error() message will tell us what was wrong with our mysql query.
How to import csv file to database through phpmyadmin
To import csv file in database though phpmyadmin, Follow the following steps.
You must have valid CSV File. EXCEL file will not work.
you must have a table in database
Number of Colums in CSV file must be equal to Number of column in table
Now login to phpmyamdin.
Make sure you server allow to upload the heavy files (If CSV is heavy).
You can update the php.ini file as following(If you CSV is less than 700MB).
upload_max_filesize = 700M post_max_size = 800M
If your CSV is more than 700MB, then increase the above values in php.ini
If you are uploading heavy files, you might need to increase the max_execution_time. (Means loading time to upload )
max_execution_time = 300000
Go to database and then go to table listing.
Click on Import link at top page
Next, Follow the steps in next.
@@@@@@
$arrayData = array(0=>'one',1=>'two',3=>'three'); print_r($arrayData); /* Array ( [0] => one [1] => two [3] => three ) */ $arrayData['4']='four'; print_r($arrayData); /** Array ( [0] => one [1] => two [3] => three [4] => four ) * */Question: How to add multiple element in array?
$arrayData = array(0=>'one',1=>'two',3=>'three'); print_r($arrayData); /* Array ( [0] => one [1] => two [3] => three ) */ $arrayData['4']='four'; $arrayData['5']='five'; print_r($arrayData); /** Array ( [0] => one [1] => two [3] => three [4] => four [5] => five ) * */Question: How to replace multiple array element with single array?
$arrayData = array(0=>'one',1=>'two',3=>'three',4=>'four',5=>'five',6=>'six'); print_r($arrayData); echo " "; /* * Array ( [0] => one [1] => two [3] => three [4] => four [5] => five [6] => six ) */ array_splice($arrayData, 1,2,array('r'=>'replaced')); print_r($arrayData); /** Array ( [0] => one [1] => replaced [2] => four [3] => five [4] => six ) * */Question: How to add element to an begining of array?
$arrayData = array(0=>'one',1=>'two',3=>'three'); print_r($arrayData); /* Array ( [0] => one [1] => two [3] => three ) */ array_unshift($arrayData, "four", "five"); print_r($arrayData); /** Array ( [0] => four [1] => five [2] => one [3] => two [4] => three ) * */Question: How to add elements at the end of array?
$arrayData = array(0=>'one',1=>'two',3=>'three'); print_r($arrayData); /* Array ( [0] => one [1] => two [3] => three ) */ array_push($arrayData, "four", "five"); print_r($arrayData); /** Array ( [0] => four [1] => five [2] => one [3] => two [4] => three ) * */
Question: How to create Model Object?
$userObj= D("Common/Users");Question: How to add simple AND Query?
$map=array(); $userObj= D("Common/Users"); $map['user_type'] = 2; $map['city_id'] = 10; $lists = $userObj ->alias("u") ->where($map) ->order("u.id DESC") ->select();Question: How to add simple OR Query?
$map=array(); $userObj= D("Common/Users"); $map['u.username|u.email'] = 'email@domain.com'; //username OR email is email@domain.com $lists = $userObj ->alias("u") ->where($map) ->order("u.id DESC") ->select();Question: How to use =, >, < in Query?
$map['id'] = array('eq',1000); //equal to 1000 $map['id'] = array('neq',1000); //Not equal to 1000 $map['id'] = array('gt',1000);//Greater than 1000 $map['id'] = array('egt',1000);//Greater than OR EQual 1000 $map['id'] = array('between','1,8'); //Between 1-8Question: How to use like Query?
$map=array(); $userObj= D("Common/Users"); $map['name'] = array('like','test%'); //like test% $lists = $userObj ->alias("u") ->where($map) ->order("u.id DESC") ->select();Question: How to use like Query with NOT?
$map=array(); $userObj= D("Common/Users"); $map['b'] =array('notlike',array('%test%','%tp'),'AND'); //Not like %test% and %tp $lists = $userObj ->alias("u") ->where($map) ->order("u.id DESC") ->select();Question: How to use Inner JOIN ?
$map=array(); $userObj= D("Common/Users"); $map['name'] = array('like','test%'); //like test% $lists = $userObj ->alias("u") ->join(C('DB_PREFIX') . "profile as p ON u.id = p.uid") ->where($map) ->order("u.id DESC") ->select();Question: How to use LEFT JOIN ?
$map=array(); $userObj= D("Common/Users"); $map['name'] = array('like','test%'); //like test% $lists = $userObj ->alias("u") ->join('LEFT JOIN '.C('DB_PREFIX') . "profile as p ON u.id = p.uid") ->where($map) ->order("u.id DESC") ->select();Question: How to use RIGHT JOIN ?
$map=array(); $userObj= D("Common/Users"); $map['name'] = array('like','test%'); //like test% $lists = $userObj ->alias("u") ->join('RIGHT JOIN '.C('DB_PREFIX') . "profile as p ON u.id = p.uid") ->where($map) ->order("u.id DESC") ->select();Question: How to use group by and having?
$map=array(); $userObj= D("Common/Users"); $map['name'] = array('like','test%'); //like test% $lists = $userObj ->alias("u") ->join('RIGHT JOIN '.C('DB_PREFIX') . "profile as p ON u.id = p.uid") ->where($map) ->order("u.id DESC") ->group('u.id') ->having('count(p.id) >0') ->select();Question: How to use count(for total records)?
$map=array(); $userObj= D("Common/Users"); $map['name'] = array('like','test%'); //like test% $count = $userObj ->alias("u") ->where($map) ->count();