Forums

custom SQL statement

awethumb 14 Jan, 2010
I need a complete SQL statement, rather than just modifying the where clause.

I am trying to run a proximity search based on latitude and longitude.
The following has worked for my purposes in the past: (less the joomla database table)

"SELECT ((ACOS(SIN($lat * PI() / 180) * SIN(lat * PI() / 180) + COS($lat * PI() / 180) * COS(lat * PI() / 180) * COS(($lng - long) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance,Name FROM #__chronoforms_CF_MYFIELD HAVING distance<='$miles' ORDER BY distance ASC"


Is it possible to insert this somehow with ChronoConnectivity?
GreyHead 14 Jan, 2010
Hi awethumb,

Techically maybe - I have a hacked version that I think could do this but really isn't yet fit to be let out into the world.

Can you do it by creating a temporary table for 'distance' and using that in the query? On second reading - no I don't think that it would :-(

Let me think some more about this . . .

Bob
awethumb 15 Jan, 2010
I have found that I can do this on an external table.
For example, I run a CRON to push the (approved) records from the CF table to an external table. I can then use php with a similar query to pull up the records. Joomla doesn't seem to like the query within its own database.
GreyHead 15 Jan, 2010
Hi awethumb,

Great, I'm glad you've got it working.

Not sure why Joomla objects though - it doesn't make any checks on the tables in the database that I know of.

Bob
awethumb 19 Jan, 2010
Apparently the SQL wrapper I am using makes use of similar name spaces. I am still having a hard time figuring this out. I will keep chipping away at it. Thanks for your insight.
awethumb 19 Jan, 2010
Joomla returns an error of
"Error loading Modules:"
repeated 8 times or so.

It seems to dislike my class. I was able to get it working by altering my class.

I had been using the wrapper from http://www.ricocheting.com/scripts/php_mysql_wrapper.php
If anyone uses it, I think the solution was setting the
$new_link=true
variable to true on or around line 71
basudec1509 31 Jan, 2010
hello guys ...


its really nice and informative post....


i just liked it....


thanks for your information guys ...........
This topic is locked and no more replies can be posted.