4

Trying to connect to 4D Database. PHPINFO says PDO is installed etc etc... Testing on localhost MAMP system. However when I run my code I get:

 Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /Applications/MAMP/htdocs/4d/index.php:12 Stack trace: #0 /Applications/MAMP/htdocs/4d/index.php(12): PDO->__construct('4D:host=127.0.0...', 'test', 'test') #1 {main} thrown in /Applications/MAMP/htdocs/4d/index.php on line 12

My code is:

$dsn = '4D:host=127.0.0.1;charset=UTF-8';
$user = 'test';
$pass = 'test';

// Connection to the 4D SQL server
$db = new PDO($dsn, $user, $pass);

try {
echo "OK";
} catch (PDOException $e) {
die("Error 4D : " . $e->getMessage());
}

Can't put my finger on the error, i'm using the settings under the PHP tab...

Thank you.

Noctis Skytower
  • 21,433
  • 16
  • 79
  • 117
Matt Reid
  • 235
  • 5
  • 14
  • 2
    You need to install the 4D driver as well. See http://www.4d.com/support/resources/features/phpintegration.html and http://pecl.php.net/package/PDO_4D – Mike Jul 24 '13 at 22:10
  • Thanks Mike, but could you advise please on how to connect that to PHP.ini? Thanks. – Matt Reid Jul 25 '13 at 02:58
  • You likely don't have to add anything to your ini file. If you are loading the correct driver, it will probably just work out of the box. If not, I really don't know. – Mike Jul 25 '13 at 19:15

2 Answers2

0

Yes, you need to install the module PDO_4D like :

pecl install channel://pecl.php.net/pdo_4D-0.3

Notes: If you use MAMP, so try :

/Applications/MAMP/bin/php/(phpversion)/bin/pecl install channel://pecl.php.net/pdo_4D-0.3

After installing, you can to verify phpinfo(); if PDO_4d has been installed correctly like :

pdo_4d

Ororuk
  • 461
  • 4
  • 17
0

Not sure if your PDO is installed, can you confirm connecting via ODBC

$odbc_string = 'DRIVER={4D v14 ODBC Driver};SSL=false;SERVER=<ip>;PORT=<19812>;UID=<user>;PWD=<password>';
$connect = odbc_connect($odbc_string,"","");

Should return is_resource on $connect

James
  • 119
  • 1
  • 8