Tuesday, 1 September 2015

MySql replace NULL values with empty string without effecting Rowset

MySql replace NULL values with empty string without effecting Rowset

Question: What is NULL Value in MySQL?
NULL values means don't have any value. It is neither empty NOR it have any value.


Question: Give an Example which is give NULL Values in Query?
NULL values means don't have any value. It is neither empty NOR it have any values.
SELECT u.id, u.first_name,u.last_name,b.address1 FROM `users` as u LEFT JOIN billings as b on b.user_id=u.id order by u.id desc limit 5;
See Screenshot below:
Give an Example which is give NULL Values in Query



Question: How we can replace the null value with empty string?
We can use mysql IFNULL function to replace the null values with empty string. See Example:
SELECT IFNULL(null,"") as value 



Question: Give an Example to replace the NULL with empty string in mysql query?
We can use mysql IFNULL function to replace the null values with empty string. See Example:
SELECT u.id, u.first_name,u.last_name,IFNULL(b.address1,"") AS address1 FROM `users` as u LEFT JOIN billings as b on b.user_id=u.id  order by u.id desc limit 5; 

See Screenhot below:
Give an Example to replace the NULL with empty string in mysql query





Friday, 21 August 2015

How to redirect http to https in Zend Framework

How to redirect http to https in Zend Framework

http to https, Follow the following:
  1. Open htaccess file in /public OR /public_html.
  2. Add following code in your .htaccess at top
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
  3. Save the File .
  4. Refresh the webpage, you will see same page is opened with https.
If you are getting infinite loop, then it means you are using CloudFlare or a similar CDN. Now instead of above code, use below one.
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]