Tuesday, 3 October 2017

method overload example in php

<?php
class TDshape {
const Pi = 3.142 ;  // constant value
 function __call($fname, $argument)
 {
    if($fname == 'area')
    {
        switch(count($argument))
    {
            case 0 : return 0 ;
            case 1 : return self::Pi * $argument[0] ; // 3.14 * 5
            case 2 : return $argument[0] * $argument[1];  // 5 * 10
    }
    }
}
}
$circle = new TDshape();
echo "Area of circle:".$circle->area(5)."</br>"; // display the area of circle
 $rect = new TDshape();
echo "Area of rectangle:".$rect->area(5,10); // display area of rectangle

?>

Monday, 25 September 2017

how to find nth salary in mysql

select  salary from (SELECT DISTINCT salary FROM employee order by salary DESC LIMIT 1)as result order by salary ASC limit 1

how to find the second max salary

select max(salary) from employee where salary <(select max(salary) from employee)

how to find the max salary in my sql

select max(salary) from employee

Friday, 15 September 2017

Wednesday, 14 June 2017