Problem with PDO::FETCH_ASSOC

Asked

Viewed 79 times

0

Hello, everybody.

I’m making a tag system for my blog. To get the tag id, I’m making a query using the IN operator. Esse código retorna

inserir a descrição da imagem aqui

I want you to return only the associative array.That’s why I use PDO::FETCH_ASSOC.

if($sql == true) {
    $result = $sql->fetchAll(PDO::FETCH_ASSOC);
}

But it returns the following error:

Fatal error: Uncaught Error: Class 'App\Models\PDO' not found in D:\xampp\htdocs\r\MeusProjetos\GreenCode3\App\Models\Editor.php:61 Stack trace: #0 D:\xampp\htdocs\r\MeusProjetos\GreenCode3\App\Controller\admin\editorController.php(45): App\Models\Editor->insert('O titulo', '13', Array, '<p>esse \xC3\xA9 o te...') #1 [internal function]: App\Controller\admin\editorController->insert('') #2 D:\xampp\htdocs\r\MeusProjetos\GreenCode3\App\Core\Core.php(101): call_user_func_array(Array, Array) #3 D:\xampp\htdocs\r\MeusProjetos\GreenCode3\index.php(15): App\Core\Core->run() #4 {main} thrown in D:\xampp\htdocs\r\MeusProjetos\GreenCode3\App\Models\Editor.php on line 61
  • 2

    When you do the PDO instance, put PDO, which will work because of the namespace

  • 1

    It worked, thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.