Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

javascript - How to pass parameters when there's no table columns (GeomFromText('Polygon (( ? ?,))) node-maria

I'm looking for a solution How to send parameters for node-maria(mysql) GeomFremText('Polygon (())').

working query

SELECT 
    GROUP_CONCAT(LINK_ID) AS LINK_LIST
FROM (SELECT DISTINCT LINK_ID FROM SCS_M_LINK WHERE mbrintersects
    (GEOM, 
    GeomFromText
        ('Polygon 
            ((
                36.46830191516196 127.24081993103029,
                36.491973470593685 127.24081993103029,
                36.491973470593685 127.33235836029054,
                36.46830191516196 127.33235836029054,
                36.46830191516196 127.24081993103029
                ))' ))) AS T1;

my backend code(query):

  `SELECT 
GROUP_CONCAT(LINK_ID) AS LINK_LIST
FROM (SELECT DISTINCT LINK_ID FROM SCS_M_LINK WHERE mbrintersects
(GEOM, 
GeomFromText
    ('Polygon (( ? ?, ? ?, ? ?, ? ?, ? ? ))' ))) AS T1;`

related code:

  const bindParams = [ parseFloat(southA), parseFloat(westA), 
            parseFloat(northA) , parseFloat(westB), parseFloat(northB), parseFloat(eastA), parseFloat(southB), 
            parseFloat(eastB), parseFloat(southC), parseFloat(westC) ]
 const result = await functions.sendQuery( query, bindParams )

These ? <- question mark doesn't work at all. I think it's becuase I'm missing matching column names, but It's in Polygon, so I do not have a column names...

Could anyone help to send the query..? other queries are working perfect. only this one doesn't work.

question from:https://stackoverflow.com/questions/66058707/how-to-pass-parameters-when-theres-no-table-columns-geomfromtextpolygon

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm just surprised by how stupid I am. Didn't think enough. I've mapped them with variable names and works perfect.

const bindParams = []
const query = `SELECT 
        GROUP_CONCAT(LINK_ID) AS LINK_LIST
        FROM (SELECT DISTINCT LINK_ID FROM SCS_M_LINK WHERE mbrintersects
        (GEOM, 
        GeomFromText
            ('Polygon (( ${ southA } ${ westA }, ${ northA } ${ westB }, ${ northB } ${ eastA }, ${ southB } ${ eastB }, ${ southC } ${ westC } ))' ))) AS T1;`

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...