In Yii-style fashion, this extension has a magic __get method that allows for accessing the items inside the protected attributes array as if they were public properties. These items can be accessed as follows:

$result->accuracy; // The accuracy code (integer)
$result->latitude; // The latitude in degrees (float)
$result->longitude; // The longitude in degrees (float)
$result->query; // The query as sent to the driver (string)
$result->clean_query; // The cleaned query string as returned by the driver (string)
$result->state; // The state name as returned by the driver (string)
$result->county; // The county name as returned by the driver (string) – Google only
$result->city; // The city name as returned by the driver (string)
$result->zip; // The zip code as returned by the driver (string)
$result->street; // The street name/address as returned by the driver (string)
$result->country; // The country code as returned by the driver (string)

All of the above listed items can also be set in the same manner. It is, however, recommended that you not override the values that are returned by the driver unless you have good reason.

There are also three public get* methods that return special data: the accuracy string, the latitude in radians, and the longitude in radians. These items can also be accessed through the magic __get method as follows:

$result->accuracy_string; // The accuracy text associated with the accuracy code (string)
$result->latitude_radians; // The latitude in radians (float)
$result->longitude_radians; // The longitude in radians (float)

A magic __isset function is also implemented which allows you to see if an item was retrieved and set by the driver, just call isset on the value. Eg: isset($result->county).

Posted in: Yii

Related FAQ's

Marius Ion ANGEL HOT SOFT LLC (800) 316-7677