要启用Firebird/InterBase支持,请配置PHP--with-interbase[=DIR],其中DIR是Firebird/InterBase base安装目录,默认为/usr。
Note: Note to Win32/Win64 Users
为了使此扩展生效, DLL 文件必须能在 Windows 系统的 PATH 指示的路径下找到。如何操作的信息,请参见题为“如何在 Windows 中将 PHP 目录加到 PATH 中”的FAQ。虽然将 DLL 文件从 PHP 文件夹复制到 Windows 系统目录也行,但不建议这样做。 此扩展需要下列文件在 PATH 路径中: fbclient.dll,gds32.dll
如果将Firebird/InterBase数据库服务器安装在运行PHP的同一台计算机上,则该DLL已经存在,fbclient.DLL、gds32.DLL(gds32.DLL是从旧版应用程序的安装程序生成的)将已经位于该路径中。
Add interbase.so to MAMP / OSX get xcode and macports. install m4 through macports download php-source corresponding to mamp-version create symblinks needed from http://www.ibexpert.net/forum/viewtopic.phpf=13&t=7&start=0&st=0&sk=t&sd=a # in short: # (backslash = keep on same row) cd /usr sudo mkdir -p local/firebird/lib sudo ln -s /Library/Frameworks/Firebird.framework/Firebird \ local/firebird/lib/libfbclient.dylib sudo ln -s /Library/Frameworks/Firebird.framework/Headers/ \ local/firebird/include #create .so sudo su cd /path-to-php-source/ext/interbase /Applications/MAMP/bin/php5/bin/phpize ./configure --with-interbase=/usr/local/firebird make #install so to mamp-ext.dir cp modules/interbase.so \ /Applications/MAMP/bin/php5/lib/ \ php/extensions/no-debug-non-zts-20050922 #add to /Applications/MAMP/conf/php5/php.ini [firebird] extension = interbase.so ibase.allow_persistent = "1" ibase.max_persistent = "-1" ibase.max_links = "-1" ibase.default_db = null ibase.default_user = NULL ibase.default_password = NULL ibase.default_charset = NULL ibase.timestampformat = "%Y-%m-%d %H:%M:%S" ibase.dateformat = "%Y-%m-%d" ibase.timeformat = "%H:%M:%S" #restart mamp - interbase should show in phpinfo #enjoy!
I tried to add extension php_interbase.dll on my php (WinXp PHP as Apche2.2 module). I had a problem while starting web server: "unable to load dynamic lybrary php_interbase.dll" Solution was to add file fbclient.dll into php folder. (Not gds32.dll)
运行时配置
这些函数的行为受php.ini中的设置影响。
| 名字 | 默认 | 可修改范围 | 更新日志 | 
|---|---|---|---|
| ibase.allow_persistent | "1" | PHP_INI_SYSTEM | |
| ibase.max_persistent | "-1" | PHP_INI_SYSTEM | |
| ibase.max_links | "-1" | PHP_INI_SYSTEM | |
| ibase.default_db | NULL | PHP_INI_SYSTEM | |
| ibase.default_user | NULL | PHP_INI_ALL | |
| ibase.default_password | NULL | PHP_INI_ALL | |
| ibase.default_charset | NULL | PHP_INI_ALL | |
| ibase.timestampformat | "%Y-%m-%d %H:%M:%S" | PHP_INI_ALL | |
| ibase.dateformat | "%Y-%m-%d" | PHP_INI_ALL | |
| ibase.timeformat | "%H:%M:%S" | PHP_INI_ALL | 
Here's an example for getting results back from stored procedure in firebird.
The example make use of the stored procedure in Employee.gdb and the show_langs procedure.
$host = 'localhost:X:/firebird/examples/Employee.gdb';
$username='SYSDBA';
$password='masterkey';
$dbh = ibase_connect ( $host, $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);
?>
If you are using VirtualHosts with Apache, you might find useful the following directive: php_flag magic_quotes_sybase on Use it in any VirtualHost and it will be set locally to that VirtualHost without interfering with any global setting. This is an example: <VirtualHost 555.666.777.888> ServerName www.samplehost.com DirectoryIndex index.php index.htm php_flag magic_quotes_sybase on </VirtualHost>
Here is a minimalistic code example. Be sure to create an user and a database in order to make it work.
<?php
// Minimalistic code example
// Connection
$db = '/path/to/database.gdb';
$user = 'username';
$password = 'password';
$res = ibase_connect($db,$dbuser,$dbpass) or die("<br>" . ibase_errmsg());
// Query
$sql="SELECT * FROM table;"
$result=ibase_query($res,$sql) or die(ibase_errmsg());
while($row=ibase_fetch_object($result)){
    // use $row->FIELDNAME not $row->fieldname
    print $row->FIELDNAME;
}
ibase_free_result($result);
// Closing
ibase_close($res) or die("<br>" . ibase_errmsg());
?>
The following code can be used when creating tables in order to get auto incrementing fields:
<?php
// This function generates an autoincrement field, such as MySQL AUTO_INCREMENT.
function generate_autoincrement($tablename,$primarykey){
    // * Generator
    dbexec('CREATE GENERATOR GEN_' . $tablename . '_PK;');
    // * Trigger
    dbexec('CREATE TRIGGER INC_' . $primarykey . ' FOR ' . $tablename
        . chr(13) . 'ACTIVE BEFORE INSERT POSITION 0'
        . chr(13) . 'AS'
        . chr(13) . 'BEGIN'
        . chr(13) . 'IF (NEW.' . $primarykey . ' IS NULL) THEN'
        . chr(13) . 'NEW.' . $primarykey . '= GEN_ID(GEN_' . $tablename . '_PK, 1);'
        . chr(13) . 'END');
}
?>
Usage: <?php generate_autoincrement('table','column name'); ?>
Hello PHP Mania,
i have made a paging for PHP with Interbase...... :)
i hope it usefull and work....:)
it`s a litle bit of example :
<?
$connection = ibase_connect($yourdb, $user, $password);
$filename = BASENAME(__FILE__);
$strsql = "Your SQL";
$result = ibase_query($connection, $strsql);
function ibase_num_rows($query) { //I have pick it from bg_idol@hotmail.com
$i = 0;
while (ibase_fetch_row($query)) {
    $i++;
  }
return $i;
}
$nrow = ibase_num_rows($result);//sum of row
$strSQL = "your SQL";
$result = ibase_query($connection, $strSQL);
if (!isset($page))
  $page = 1;
$$i = 0;
$recperpage = 4;
$norecord = ($page - 1) * $recperpage;
if ($norecord){
  $j=0;
  while($j < $norecord and list($code, $name)= ibase_fetch_row($result)){
  $j++;
  }
}
echo "<table>";
while (list($code, $name)= ibase_fetch_row($result) and $i < $recperpage){
  ?>
    <tr>
        <td width="5%"><? echo $code; ?></td>
        <td><? echo $name; ?></td>
    </tr>
<?
$i++;
}
$incr = $page + 1;
if ($page > 1) $decr = $page - 1;
$numOfPage = ceil($nrow/$recperpage);
?>
    <tr>
<td colspan="3" align="center"><?if ($page <= 1)
                    echo "<span>Prev</span>";
                  else
                      echo "<a href=".$filename."?page=".$decr.">Prev</a>";
                ?>
                  
                <?if ($page == $numOfPage)
                    echo "<span>Next</span>";
                  else
                      echo "<a href=".$filename."?page=".$incr.">Next</a>";?>
</td>
</tr>
</table>
