pdo and firebird connection

php.internals

Michael Maier

21 years ago
Hi, I´ve trying now for hours just to connect with PDO to my firebird DB. I tried it first with a mysql db and had no problems at all. but it doesn´t work with firebird and I don´t know why (haven´t found anything helpful via google as well). I tried to use the manual from here: http://de3.php.net/manual/de/function.pdo-construct.php with the code below, I get always the error message: Fatal error: Call to a member function getAttribute() on a non-object in K:\_workspace\test1\pdo3.php on line 7 a test with the interbase driver works well (see in the code comments). => is the code correct? => where is the error!? => does the PDO firebird driver work? thx a lot for help, Michael <?php $username = 'SYSDBA'; $password = 'xxxxxx'; $dbh = new PDO( 'firebird:User=SYSDBA;Password=xxxxxx;Database=k:\_firebird\examples\EMPLOYEE.FDB;DataSource=localhost;Port=3050', $username, $password ); //$dbh = new PDO( 'firebird:User=SYSDBA;Password=xxxxxx;Database=k:\_firebird\examples\EMPLOYEE.FDB;DataSource=localhost;Port=3050' ); print $dbh->getAttribute(PDO_ATTR_AUTOCOMMIT); // <==Fatal error here! $stmt = $dbh->prepare("Select * from SHOW_LANGS('SRep',4,'Italy')"); $stmt->execute(); $stmt = null; /* // test with ibase driver $dsn = 'localhost:k:\_firebird\examples\employee.fdb'; $dbh = ibase_connect ( $dsn, $username, $password ) or die ("error in db connect"); $stmt="Select * from SHOW_LANGS('SRep',4,'Italy')"; $query = ibase_prepare($stmt); $rs=ibase_execute($query); $row = ibase_fetch_row($rs); echo $row[0]; // free result ibase_free_query($query); //ibase_free_result($rs); // close db ibase_close($dbh); */ ?>

Michael Maier

21 years ago
Michael Maier wrote:
> Hi, > > I´ve trying now for hours just to connect with PDO to my firebird DB. > I tried it first with a mysql db and had no problems at all. but it > doesn´t work with firebird and I don´t know why (haven´t found anything > helpful via google as well). > > I tried to use the manual from here: > http://de3.php.net/manual/de/function.pdo-construct.php > > with the code below, I get always the error message: > Fatal error: Call to a member function getAttribute() on a non-object in > K:\_workspace\test1\pdo3.php on line 7 > > a test with the interbase driver works well (see in the code comments). > > => is the code correct? > => where is the error!? > => does the PDO firebird driver work? > > thx a lot for help, > > Michael > > <?php > $username = 'SYSDBA'; > $password = 'xxxxxx'; > > $dbh = new PDO( > 'firebird:User=SYSDBA;Password=xxxxxx;Database=k:\_firebird\examples\EMPLOYEE.FDB;DataSource=localhost;Port=3050', > $username, $password ); > //$dbh = new PDO( > 'firebird:User=SYSDBA;Password=xxxxxx;Database=k:\_firebird\examples\EMPLOYEE.FDB;DataSource=localhost;Port=3050' > ); > print $dbh->getAttribute(PDO_ATTR_AUTOCOMMIT); // <==Fatal error here! > $stmt = $dbh->prepare("Select * from SHOW_LANGS('SRep',4,'Italy')"); > $stmt->execute(); > $stmt = null; > > /* > // test with ibase driver > $dsn = 'localhost:k:\_firebird\examples\employee.fdb'; > $dbh = ibase_connect ( $dsn, $username, $password ) or die ("error in db > connect"); > $stmt="Select * from SHOW_LANGS('SRep',4,'Italy')"; > $query = ibase_prepare($stmt); > $rs=ibase_execute($query); > $row = ibase_fetch_row($rs); > echo $row[0]; > // free result > ibase_free_query($query); > //ibase_free_result($rs); > // close db > ibase_close($dbh); > */ > > ?>
Michael Maier wrote:
> Hi, > > I´ve trying now for hours just to connect with PDO to my firebird DB. > I tried it first with a mysql db and had no problems at all. but it > doesn´t work with firebird and I don´t know why (haven´t found anything > helpful via google as well). > > I tried to use the manual from here: > http://de3.php.net/manual/de/function.pdo-construct.php > > with the code below, I get always the error message: > Fatal error: Call to a member function getAttribute() on a non-object in > K:\_workspace\test1\pdo3.php on line 7 > > a test with the interbase driver works well (see in the code comments). > > => is the code correct? > => where is the error!? > => does the PDO firebird driver work? > > thx a lot for help, > > Michael > > <?php > $username = 'SYSDBA'; > $password = 'xxxxxx'; > > $dbh = new PDO( >
'firebird:User=SYSDBA;Password=xxxxxx;Database=k:\_firebird\examples\EMPLOYEE.FDB;DataSource=localhost;Port=3050',
> $username, $password ); > //$dbh = new PDO( >
'firebird:User=SYSDBA;Password=xxxxxx;Database=k:\_firebird\examples\EMPLOYEE.FDB;DataSource=localhost;Port=3050'
> ); > print $dbh->getAttribute(PDO_ATTR_AUTOCOMMIT); // <==Fatal error here! > $stmt = $dbh->prepare("Select * from SHOW_LANGS('SRep',4,'Italy')"); > $stmt->execute(); > $stmt = null; > > /* > // test with ibase driver > $dsn = 'localhost:k:\_firebird\examples\employee.fdb'; > $dbh = ibase_connect ( $dsn, $username, $password ) or die ("error in db > connect"); > $stmt="Select * from SHOW_LANGS('SRep',4,'Italy')"; > $query = ibase_prepare($stmt); > $rs=ibase_execute($query); > $row = ibase_fetch_row($rs); > echo $row[0]; > // free result > ibase_free_query($query); > //ibase_free_result($rs); > // close db > ibase_close($dbh); > */ > > ?>
ok, for everybody who is playing with the pdo firebird driver as well: ---------------------- do for example the connection like this (not like the link to the manual from above): <?php $user = "SYSDBA"; $password = "xxx"; $test_base = "localhost:k:\x_test\PDO\TEST.FDB"; $dbh = new PDO("firebird:dbname=$test_base",$user,$password) or die; ?> ---------------------- try catch doesn´t work (no exception is thrown): <?php ... try { $db = new PDO("firebird:dbname=$test_base",$user,$password); } catch( PDOException $e ) { die( $e->getMessage() ); } ?> ---------------------- all the other examples form http://netevil.org/node.php?nid=44&SC=1 have worked. but be careful with the column named "value". better use a different name e.g. "val" or whatever (I´ve had problems here). ---------------------- like Lester said, Ard is busy right now. but he told me he will take some time in the near future to fix the current issues. thx, Michael