Siva
Siva

Reputation: 509

Typoscript issue with GP vars?

I want to execute a query using typoscript . My query is

SELECT * FROM TABLE where sld like '{GP:SID}' . I want to warp the SID variable inside a single/double quotes. Tried the below script, but didnt worked for me.

lib.products = CONTENT
lib.products {
  table = TABLE
  select {
    pidInList = 26506
      orderBy = name
      where = sid like '{GP:SID}'
   }
   renderObj = COA
   renderObj {
   10 = COA
     10 {
     10 = TEXT
     10.dataWrap ={field:name}[\n]
    }
  }

}

Can any help me with this ?

Upvotes: 0

Views: 687

Answers (1)

Viktor Livakivskyi
Viktor Livakivskyi

Reputation: 3228

You code is insecure! Don't use it on production.

What you should do instead - is to use TS query markers, which uses prepared statements in a background.

lib.products = CONTENT
lib.products {
  table = TABLE
  select {
    pidInList = 26506
      orderBy = name
      where = sid like '###sid###'
      markers {
        sid.data = GP:SID
      }
   }
   renderObj = COA
   ...
}

Also, if you want to use LIKE, you need % sign to make it work, otherwise it is same as 'equals', but slower. However, I'm not sure, what happens, if GP:SID contains % sign at the beginning or at the end of a string.

Upvotes: 6

Related Questions