Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

540
Visualizações
Undefined class constant 'PDO::FETCH_DEFAULT'

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' => 'admin@example.com'])
    ->select('id, name, email, password', true)
    ->fetchAll();

The error is:

Undefined class constant 'PDO::FETCH_DEFAULT'

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

PHP version is 7.4

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.

over 4 years ago · Santiago Trujillo Relatório

0

This package seems to have a configuration error. Current stable version declares PHP/7.1 as minimum version (code):

"php": ">=7.1",

However it's using the PDO::FETCH_DEFAULT constant, which requires PHP/8.0.7 or greater (source and code):

PDO::FETCH_DEFAULT (int) Specifies that the default fetch mode shall be used. Available as of PHP 8.0.7.

/** @var int */
protected $currentFetchMode = PDO::FETCH_DEFAULT;

Your options are:

  • Report the issue and hope it's fixed by maintaining backwards compatibility with your PHP version. Edit: https://github.com/envms/fluentpdo/issues/326
  • Upgrade to a supported PHP version.
  • Find another library.
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda