think-orm icon indicating copy to clipboard operation
think-orm copied to clipboard

PHP8.1中连接使用pgsql报strpos(): Passing null to parameter #1 ($haystack) of type string is deprecate错

Open hlinfocc opened this issue 3 years ago • 0 comments

报错信息

截图_选择区域_20220817223147

原因

$val['extra']可能为null,导致报错,strpos的第一个参数不能为null(php8.1以前可以为null)

解决办法

将vendor/topthink/think-orm/src/db/connector/Pgsql.php的76行改为:

'autoinc' => (empty($val['extra'])?0:(0 === strpos($val['extra'], 'nextval('))),

修改后如下图:

截图_选择区域_20220817224322

hlinfocc avatar Aug 17 '22 14:08 hlinfocc