How to Connect from Php to Firebird 1.5 ?

125 views
Skip to first unread message

Maxim Symfony

unread,
Jul 15, 2021, 1:04:03 PM7/15/21
to firebird-support
Hello,
Can not find driver ?
Warning: ibase_connect(): operating system directive access failed Not a directory

public function number(): Response
{
$number = random_int(0, 100);
$username = 'SYSDBA';
$password = 'masterkey';
$dbLink = 'localhost/3050:/home/mxm/PhpstormProjects/noom_api/db/noom.fdb';
$link = '/home/mxm/PhpstormProjects/noom_api/db/noom.fdb';
$pdoFire = 'firebird:dbname=127.0.0.1:/home/mxm/PhpstormProjects/noom_api/db/noom.fdb;charset:ISO8859_1,SYSDBA,masterkey';
$pdoFire = 'firebird:dbname=localhost:/home/mxm/PhpstormProjects/noom_api/db/noom.fdb;charset:ISO8859_1,SYSDBA,masterkey';
// $pdoFire = 'firebird:dbname=/home/mxm/PhpstormProjects/noom_api/db/noom.fdb;charset:ISO8859_1,SYSDBA,masterkey';
// $pdoFire = 'firebird:dbname=/home/mxm/PhpstormProjects/noom_api/db/noom.fdb';

// $fire = new \PDO($pdoFire, $username, $password);

// $obcd = odbc_connect($dbLink, $username, $password);
$dbcon = \ibase_connect($link, $username, $password);
//
// $stmt = 'SELECT * FROM tblname';
// $sth = \ibase_query($fire, $stmt);
// while ($row = \ibase_fetch_object($sth)) {
// echo $row->email, "\n";
// }
// \ibase_free_result($sth);
// \ibase_close($dbcon);


return $this->render('lucky/number.html.twig', [
'number' => $number,
]);

Mark Rotteveel

unread,
Jul 15, 2021, 1:06:52 PM7/15/21
to firebird...@googlegroups.com

Please ask this question on https://groups.google.com/g/firebird-php,
that group is more suitable for Firebird and PHP related questions.

Mark (moderator)

Matthias Hanft

unread,
Jul 15, 2021, 1:29:09 PM7/15/21
to firebird...@googlegroups.com
Maxim Symfony schrieb:
> Warning: ibase_connect(): operating system directive access failed Not a directory

Do not use ibase... any more. It was removed as of PHP 7.4.

> $pdoFire = 'firebird:dbname=127.0.0.1:/home/mxm/PhpstormProjects/noom_api/db/noom.fdb;charset:ISO8859_1,SYSDBA,masterkey';

The correct syntax is:

$pdoFire = 'firebird:dbname=127.0.0.1:/home/mxm/PhpstormProjects/noom_api/db/noom.fdb;charset=ISO8859_1;dialect=3';
$fire = new PDO($pdoFire, $username, $password);
$fire->setAttribute(PDO::FB_ATTR_DATE_FORMAT, '%F'); // 2020-12-31
$fire->setAttribute(PDO::FB_ATTR_TIME_FORMAT, '%T'); // 12:34:56
$fire->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, '%F %T'); // %s would be unix timestamp if needed

-Matt

Mark Rotteveel

unread,
Jul 15, 2021, 3:16:36 PM7/15/21
to firebird...@googlegroups.com
On 2021-07-15 19:29, Matthias Hanft wrote:
> Maxim Symfony schrieb:
>> Warning: ibase_connect(): operating system directive access failed Not
>> a directory
>
> Do not use ibase... any more. It was removed as of PHP 7.4.

It was removed from the PHP distribution because the PHP developers
didn't want to be responsible for it. It is now maintained on
https://github.com/FirebirdSQL/php-firebird, and you need to install it
yourself.

Mark
Reply all
Reply to author
Forward
0 new messages