Fatal error class pdo not found in

Обычный хостинг на Ru-Center. PHP 7.
Расширения PDO и PDO_MYSQL включены.
Фреймворк Yii2.

При попытке выполнить миграцию.

php yii migrate

PHP Fatal Error ‘yiiaseErrorException’ with message ‘Class ‘PDO’ not found’

Обратился к хостеру. Посоветовали выполнять команду следующего вида:

Но результатом этой команды выводится следующая ошибка:

Exception ‘yiidbException’ with message ‘SQLSTATE[HY000] [2002] No such file or directory’


Добрый день!
В php я не силен, а потому сильно не пинайте.
По наследству досталось поддержка сайта на фреймворк Kohana(написано на php).
При попытке связаться с удаленным Oracle вываливается ошибка:

ErrorException [ 1 ]: Class ‘PDO’ not found

Сервера: линукс.
Коннект к базе:
$query = DB::query(Database::SELECT, ‘select current_date() as date’);

44 строка в pdo.php
// Force PDO to use exceptions for all errors

Как бы есть предположение, что не стоят библиотеки pdo, oci.

Ideas as to why I’m getting this error?

PHP 5.3.15 CloudLinux/CentOS 6 CPanel

10 Answers 10

Try adding use PDO; after your namespace or just before your class or at the top of your PHP file.

This can also happen if there is a php.ini file in the web app’s current working directory. If one has been placed there to change certain settings, it will override the global one.

To avoid this problem, don’t use a php.ini file to change settings; instead you can:

  • Specify settings in the vhost declaration
  • Use an .htaccess file with php_flag (see here)
  • Use an .user.ini file (see here)

Ensure they are being called in the php.ini file

If the PDO is displayed in the list of currently installed php modules, you will want to check the php.ini file in the relevant folder to ensure they are being called. Somewhere in the php.ini file you should see the following:

If they are not present, simply add the lines above to the bottom of the php.ini file and save it.

What is the full source of the file Mysql.php . Based on the output of the php info list, it sounds like you may be trying to reference a global class from within a namespace.

If the file Mysql.php has a statement "namespace " in it, use PDO in place of PDO — this will tell PHP to look for a global class, rather than looking in the local namespace.

I had the same problem on GoDaddy. I added the extension=pdo.so to php.ini , still didn’t work. And then only one thing came to my mind: Permissions

Before uploading the file, kill all PHP processes(cPanel->PHP Processes).

The problem was that with the file permissions, it was set to 0644 and was not executable . You need to set the file permission at least 0755 .

Оцените статью
Много толка
Добавить комментарий