hello,
I’m trying to create a ZIP code field in a CGridView, so when I search for a specific ZIP code it’d return the closest addresses in (ie) a 10mile radius.
has anybody heard of an extension or anything like that?
thx,
–iM
hello,
I’m trying to create a ZIP code field in a CGridView, so when I search for a specific ZIP code it’d return the closest addresses in (ie) a 10mile radius.
has anybody heard of an extension or anything like that?
thx,
–iM
Does your zip table have the geo-coordinates?
Are your addresses geo-coded?
Here how I use it in the model. I though of extension but did not buy it.
$sql = "SELECT P.*,
3956 * 2 * ASIN(SQRT( POWER(SIN(($lat - lat) * pi()/180 / 2), 2)
+ COS($lat * pi()/180) * COS(lat * pi()/180)
* POWER(SIN(($lon - lon) * pi()/180 / 2), 2) )) AS distance
FROM fsd.products P
HAVING distance <= $miles
ORDER BY distance, impression LIMIT $limit";
$dataReader = Yii::app()->db->createCommand($sql)->query();
$data = $dataReader->readAll();
Unfortunately I only have the ZIP code in my table right now, so first I have to find the coordinates (so it will be an extra step 
thanks for the query btw
–iM
That is a pretty good query… Thanks for it Pradham!!!