How to escape sql injection from HANA placeholder

后端 未结 1 1426
失恋的感觉
失恋的感觉 2021-01-25 01:41

I have some HANA queries which use PLACEHOLDER input and of course I want to prevent an sql injection.

I try to use ? in odbc_prepare()

相关标签:
1条回答
  • 2021-01-25 02:04

    The (old) placeholder syntax ('PLACEHOLDER'=('<varname>', '<var value>')) you're using here does not allow for bind variables.

    Instead, the new placeholder syntax (PLACEHOLDER."<varname>"=>?) allows using bind variables.

    In your code this would look like this:

    $query = <<<SQL
    SELECT
        col,
        ...
    FROM table_name (PLACEHOLDER."$$some_key$$" => ?)
    WHERE col = ?
    SQL;
    $stmt = \odbc_prepare($conn, $query);
    
    0 讨论(0)
提交回复
热议问题