Skip to main content

Posts

Showing posts with the label query

PostGIS function to connect geometry LINE together?

(note: the_geom is a geometry value (TYPE: LINESTRING), in this case i random them for readability) gid | kstart | kend | ctrl_sec_no | the_geom | the_sum_geom 626 | 238 | 239 | 120802 | 123456 | NULL 638 | 249 | 250 | 120802 | 234567 | NULL 4037| 239 | 249 | 120802 | 345678 | NULL [Real Practice Description] just skip this for those who don't mind the purpose I would like to do 'this' (a set of queries from my past question, link located on the end of this post) for every row in Table B (aka. land_inventory). These two tables are related by 'ctrl_sec_no' (aka. control section number of a road) which means :: in ONE ctrl_sec_no -- 120802 (in fact, it is a road which is equivalent to 3 geometry LINESTRINGs (the_geom) connected together, from kstart 238 (start at kilometre of 238) to kend 250) [PostGIS question] the question is how to connect this 3 lines {aka gid(626,638,4037) from the table} together a

Replacing special characters like dots in javascript

I have a search query from the user and I want to process it before applying to browser. since I'm using SEO with htaccess and the search url looks like this : /search/[user query] I should do something to prevent user from doing naughty things.. :) Like searching ../include/conf.php which will result in giving away my configuration file. I want to process the query like removing spaces, removing dots(which will cause problems), commas,etc. var q = document.getElementById('q').value; var q = q.replace(/ /gi,"+"); var q = q.replace(/../gi,""); document.location='search/'+q; the first replace works just fine but the second one messes with my query.. any solution to replacing this risky characters safely?

Format MySQL Select into Associative Array in CakePHP

I like how CakePHP automatically loops through the results of MySQL queries and formats them in a nice map for you. Here's a sample query that I'm using: # Inside some model return $this->query(" SELECT Profile.id, SUM( IF( HOUR(Log.event_one) > 3, 1, 0 ) ) as EventOne FROM profiles Profile JOIN logs Log ON Log.id = Profile.log_id WHERE Profile.id = {$pUserId} "); CakePHP would return a map like the following as the result: array 0 array 'Profile' array 'id' => 23 '0' array 'EventOne' => 108 1 array 'Profile' array 'id' => 23 '0' array 'EventOne' => 42 2 ... What I'm trying to do is have the result be something like this: array 'Profile' array 'id' => 23 'Events' # ^ I want to be ab