I’m using PHP FluentPDO, this query works in localhost, but not in webhosting. PHP version is 7.4, FluentPDO: "envms/fluentpdo": "^2.2"
:
$pdo = new PDO("mysql:dbname={$mysql['db_name']};host={$mysql['host']}", $mysql['user'],
$mysql['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'", PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC));
$q = new Query($pdo);
$q->from('table')
->where(['email' => '[email protected]'])
->select('id, name, email, password', true)
->fetchAll();
The error is:
Undefined class constant ‘PDO::FETCH_DEFAULT’
2
Answers
This PHP version is no longer supported. Please upgrade to an actively supported version if you can.
PDO::FETCH_DEFAULT
is available only since PHP 8.0.7, so if you are using an earlier version, this constant will not be available.FluentPDO version 2.2 should still support PHP 7.4, which makes this a bug in FluentPDO. There already exists a pull request to fix this bug.
This package seems to have a configuration error. Current stable version declares PHP/7.1 as minimum version (code):
However it’s using the
PDO::FETCH_DEFAULT
constant, which requires PHP/8.0.7 or greater (source and code):Your options are: