yii: SQLSTATE[IM001]: Driver does not support this function: driver does not support quoting when using the driver pdo_odbc on php 8.0.1

What steps will reproduce the problem?

The pdo_odbc driver does not support the PDO :: quote method, which follows from the documentation https://www.php.net/manual/ru/pdo.quote.php It is advised to use prepared queries instead. But, when using the IN construct in QueryBuilder, for example -> where (['in', 'wp.this_url', $ genreUrls]), the quoteValue call occurs implicitly, which ultimately results in a driver does not support error call quoting.

I suggest adding a check in quoteValue and quoteValueWithType if the odbc driver does not call PDO :: quote

Additional info

Q A
Yii version 1.1.23
PHP version 8.0.1
Operating system

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24 (15 by maintainers)

Most upvoted comments

@marcovtwout It works correct

@emenshov I don’t think the PHP8 condition is actually neccessary. You can check the driver name with https://www.yiiframework.com/doc/api/1.1/CDbConnection#getDriverName-detail instead of doing string matching yourself. Finally you can avoid duplicate fallback code by structuring the whole thing something like this:

if (drivername !== 'obdc')
    if ($value = pdo::quote() !== false)
        return $value
    
return addcslashes fallback

It seems the error cannot be suppressed because of bug https://bugs.php.net/bug.php?id=71941

I’m not sure if this should be fixed on the PHP side or have a workaround applied on the framework side. I suggest to report this issue in the Yii 2 issue tracker as well. Whatever solution is chosen there, I will consider to apply here.