Friday, July 6, 2012

bounce php-fpm

To stop

killall -w -v php-fpm

-w is to wait for the processes selected to stop
-v verbose

I observed that few php-fpm processes took time to stop (might be they are wrapping up stuff). Immediately starting php-fpm after passing the killall command without -w might cause error (port in use or unix socket in use).

Another important point. In case if you are running php-fpm in the unix socket mode then make sure to bounce your server in case you are bouncing php-fpm. I follow this

stop server && stop php-fpm && start php-fpm && start server

Sunday, April 1, 2012

SQL- distinct

select distinct city, college_name from students

> so the combination of city and college should be distinct we can not have it like

select city, distinct college_name from students

but we can have it with an aggregate e.g. for each city give me the count of distinct colleges :) eh!

select city, count(distinct college_name) from students

postgres - from clause in update sql

update students set college_name = c.name from colleges c
where students.city = c.city

weired SQL but awesome isn't??!!

> In update we cannot use aliases for the update table so have to use the full name in case of ambiguous columns e.g. city

> we can have any number of from tables with aliases and have a join on the update table and also can update a value using a value from the join table

Monday, March 5, 2012

SQL: exists

Today I figured out that we can use sql "exists" in the select part of a query

e.g. select name, exists (select 1 from girls where bf_name = boys.name) has_bf from boys b

result:
name has_bf
------------
A t
B f
C t

Monday, February 6, 2012

SOAP and PHP

Calling a SOAP based service could not be this easy as it can be done with PHP
        $objClient = new SoapClient("http://foobar.in/services/blahblah?wsdl", array('trace' => true));
    
        $objResponse = $objClient->getGreeting(array("name" => "tom"));
    
        //print($objClient->__getLastRequest());        
        print_r($objResponse);
$objResponse
stdClass Object
(
    [out] => stdClass Object
        (
            [message] => Hello tom!
        )
)