1

I know this error message has been described before and I've tried the fixes like adding pdo.so to php.ini etc.

The main difference I have is PDO works fine for the websites on the server I'm running - it just fails for commandline scripts I use to update the database. So essentially it works but not in all situations.

This was working before I upgraded to PHP7.0.8/9

sudo yum list installed php70*
Loaded plugins: priorities, replace, update-motd, upgrade-helper
958 packages excluded due to repository priority protections
Installed Packages
php70.x86_64                 7.0.8-1.13.amzn1                      @amzn-updates
php70-cli.x86_64             7.0.8-1.13.amzn1                      @amzn-updates
php70-common.x86_64          7.0.8-1.13.amzn1                      @amzn-updates
php70-json.x86_64            7.0.8-1.13.amzn1                      @amzn-updates
php70-php-bcmath.x86_64      7.0.9-1.el6.remi                      @remi-safe
php70-php-cli.x86_64         7.0.9-1.el6.remi                      @remi-safe
php70-php-common.x86_64      7.0.9-1.el6.remi                      @remi-safe
php70-php-fpm.x86_64         7.0.9-1.el6.remi                      @remi-safe
php70-php-gd.x86_64          7.0.9-1.el6.remi                      @remi-safe
php70-php-json.x86_64        7.0.9-1.el6.remi                      @remi-safe
php70-php-mbstring.x86_64    7.0.9-1.el6.remi                      @remi-safe
php70-php-mcrypt.x86_64      7.0.9-1.el6.remi                      @remi-safe
php70-php-mysqlnd.x86_64     7.0.9-1.el6.remi                      @remi-safe
php70-php-opcache.x86_64     7.0.9-1.el6.remi                      @remi-safe
php70-php-pdo.x86_64         7.0.9-1.el6.remi                      @remi-safe
php70-php-pear.noarch        1:1.10.1-4.el6.remi                   @remi-safe
php70-php-pecl-igbinary.x86_64
                             1.2.2-0.2.20160715gita87a993.el6.remi @remi-safe
php70-php-pecl-redis.x86_64  3.0.0-1.el6.remi                      @remi-safe
php70-php-process.x86_64     7.0.9-1.el6.remi                      @remi-safe
php70-php-xml.x86_64         7.0.9-1.el6.remi                      @remi-safe
php70-process.x86_64         7.0.8-1.13.amzn1                      @amzn-updates
php70-runtime.x86_64         1.0-5.el6.remi                        @remi-safe
php70-xml.x86_64             7.0.8-1.13.amzn1                      @amzn-updates

Is there a way to manually include PDO Class?

Any reason why this would fail only on commandline? Note: I'm using the same database.class.php (that I've written) for both web and commandline - same class but different results.

thoughts?

Adam
  • 19,932
  • 36
  • 124
  • 207
  • Are you using a Red Hat or Centos? tbh it could be other flavors as well but i would guess your path in bash points to the wrong php executable. Honestly it's hard to say though – bassxzero Jul 29 '16 at 00:07
  • yes Centos - ok I'll have a look at the path... thankyou – Adam Jul 29 '16 at 00:09
  • Maybe its the mix of PHP .8 and .9 - the installs are coming form 2 different locations - remi and amzn – Adam Jul 29 '16 at 00:13
  • It sounds like you have a `namespace` statement somewhere in your script, so in that case you'd need to instantiate the PDO object with a backslash for the root namespace `$pdo = new \PDO` – Jeff Puckett Jul 29 '16 at 00:14
  • I tried the \PDO but same outcome - thanks for the idea :) – Adam Jul 29 '16 at 00:19
  • 3
    You likely have two different `php.ini` config files; one for web and another for CLI. Run `php -i` in your console and see what configuration files are loaded. The CLI one probably doesn't have the PDO and pdo_mysql extensions loaded. See http://stackoverflow.com/questions/3057110/where-can-i-find-the-php-ini-for-php-cli – Phil Jul 29 '16 at 00:20
  • yes php -i does not have any reference to pdo - thanks I'll try the stack link - appreciated – Adam Jul 29 '16 at 00:23
  • Have you restarted Apache? You can use to check if PDO has been loaded. – user2182349 Jul 29 '16 at 01:01

1 Answers1

1

You have 2 different PHP stacks installed.

  • php70-* (7.0.8 from amzn), those are probably "base" packages, and probably provide /usr/bin/php, but don't have the PDO extension (php-pdo package)

  • php70-php-* (7.0.9 from remi), which is a Software Collection, design for parallel installation, which provide the php70 command (you can also use "scl enable php70 php" command)

More information about SCL in Remi's FAQ

Remi Collet
  • 6,198
  • 1
  • 20
  • 25
  • You were exactly right and it's so obvious now. I've removed the AWS php packages and reinstall php via remi. All is on the same version now and everything is working. greatly grealy greatly appreciate your time... THANKS!!! – Adam Jul 29 '16 at 06:17