peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.33k stars 202 forks source link

PDOSqlServerDriver does not implement Quote method #1058

Closed Alikont closed 2 years ago

Alikont commented 2 years ago

PDOSqlServerDriver does not implement Quote method.

As a workaround we created custom implementation of PDOSqlServerDriver by subclassing it, and overriding it in PDOEngine, via workaround specified in #1057

public override string Quote(string str, PDO.PARAM param)
{
    if (string.IsNullOrEmpty(str))
    {
        return "''";
    }
    else
    {
        return $"'{str.Replace("'", "''")}'";
    }
}