Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82264

Parameters in a Sub Select

$
0
0

I am using a Sub Select in a where clause and have it working with static values.

    ->where( function ( $q ) {
           $q->where( 'segment_id', '(SELECT map_id FROM maps WHERE ST_DWithin(geog, ST_GeomFromText(\'POINT(-122.1640 37.4321)\',4326),1000))', 'IN', false );
    } )

This populates a table correctly using this postgis based query. All good at this point.
I then wanted to pass the latitude/longitude values in from the calling javascript file.

I defined the values as follows:

            ajax: {
                    url: 'php/table.location.php',
                    type: 'POST',
                    data: function ( d ) {
                            d.longitude = "-122.1640";
                    }
            },

And then modified the where clause to take the longitude from the above parameter.

            $q->where( 'segment_id', '(SELECT map_id FROM maps WHERE ST_DWithin(geog, ST_GeomFromText(\'POINT(:longitude 37.4321)\',4326),1000))', 'IN', false );
            $q->bind( ':longitude', $_POST['longitude'] );

But it gives me an error:
DataTables warning: table id=fibers - SQLSTATE[HY093]: Invalid parameter number: :longitude

I've done some basic testing passing the parameter to a much simpler Sub select and it works fine so I am pretty sure its something to do with the POINT part of the SQL query thats messing it up.

Any suggestions?


Viewing all articles
Browse latest Browse all 82264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>