cackphp log queries without layout

if (Configure::read('debug') == 2) {
$db = ConnectionManager::getDataSource('default');

simplexml_load_string with multiple options

Following is example of how you can pass multiple parameters.

$XML = simplexml_load_string($XmlString, 'SimpleXMLElement', LIBXML_NOBLANKS | LIBXML_NOCDATA | LIBXML_NOEMPTYTAG);


Google API to get latitude longitude from address

Here is PHP code to get latitude longitude form Address.

$address = "Put Your Address Here";
$prepAddr = str_replace(' ','+',$address);
$geocode = file_get_contents(''.$prepAddr.'&sensor=false');
$output = json_decode($geocode , true);
if ($output['status'] == 'OK') {
	$latitude = $output['results'][0]['geometry']['location']['lat'];
	$longitude = $output['results'][0]['geometry']['location']['lng'];

source :

Web Service high level explanation

following is some of details regarding web services as per my best knowledge:


  1.  XML-RPC : Very old approach :
  2. SOAP : Refined version of XML-RPC
  3. REST : API Latest trend


  1. xml based
  2. Few basic data types supported(String,integer,array,date…)
  3. Library available in most languages
  4. Transport protocol http/https

1) xml based
2) Extensive data types supported, UDF(User defined data types) as well
3) Server and client libraries are available in almost all languages.
4) Transport protocol http/https, smtp


  1. json/xml based
  2. Supported data types are : integer, staring, array, object
  3. REST describes architecture style while leaving implementation as per your choice.Ready made might not available.
  4. Transport protocol http/https
  5. Faster and flexible ( response format is based on http headers: xml or json)
  6. json is compressive format then xml as it saves about 30%-40% bytes on network(e.g. xml have open and close tags)

Following are key points which we needs to consider to boost development while working with web services:

  1. security – must be very secure
  2. handy – easy to consume (xml parsing is pain sometimes a complex xml might take 8-10 hours to parse and change in format might take become log faulty taks, json parsing is very easy and there is very low chance of having bugs. it will take just one line of code and parsing time will be about 5 mins job with testing.)
  3. debugging – easy to debug
  4. fast response – it depends on processing on server + size of data traverse on network
  5. well defined data structure : will make api easy to understand

In general Web service is sending data to server and receiving data back the same way we do in database servers but web services are more then querying database.

– Yogs