/ Published in: PHP
This is damn crazy! sQlite does not have all the trig functions need to do distances. So here is how you load that into sQlite on the fly.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$db = new PDO('sqlite:db/database.sqlite'); $db->sqliteCreateFunction('distance', function () { foreach( $geo as $k => $v ) { } }, 4); $pp = 25; $offset = 0; } $q = "SELECT oc.content_id, distance( ( SELECT value_text FROM contents INNER JOIN contentvalues ON value_content_id = content_id INNER JOIN typefields ON value_field_id = field_id WHERE field_alias = 'latitude' AND content_id = oc.content_id ) , ( SELECT value_text FROM contents INNER JOIN contentvalues ON value_content_id = content_id INNER JOIN typefields ON value_field_id = field_id WHERE field_alias = 'longitude' AND content_id = oc.content_id ) , $lat , $lng ) AS dis FROM contents AS oc WHERE ".time()." BETWEEN content_publish_start_date AND content_publish_end_date ". "ORDER BY dis ASC LIMIT $offset , $pp";
URL: http://www.itsgotto.be/cv