Document Type | Technical Information
Category | Interface/Integration
Applicable Product Versions | Tibero6, Tibero7
Document Number | TIITI064
Overview
This document explains how to integrate PHP 8.1 with unixODBC to connect to the Tibero7 database using ODBC on a Linux environment.
This guide installs PHP by compiling from source and aims to verify ODBC connection in the CLI environment.
Test Environment
| Item | Details |
|---|---|
| OS | Linux (x86_64) |
| Tibero | Tibero7.2.4 |
| unixODBC | 2.3.14 |
| PHP | 8.1.29 |
| Compiler | gcc |
| ODBC Driver | Tibero ODBC Driver (libtbodbc.so) |
Prerequisites
Tibero7 installation and Listener running status
Verification of Tibero ODBC Driver (
libtbodbc.so)gcc, make, autoconf installed
file $TB_HOME/client/lib/libtbodbc.so
Method
Installing unixODBC
Download Source
wget https://www.unixodbc.org/unixODBC-2.3.14.tar.gz
cd /home/test7/unixodbc
tar -xzvf unixODBC-2.3.14.tar.gz
Compile and Install
cd /home/test7/unixodbc/unixODBC-2.3.14
./configure --prefix=/home/test7/unixodbc/install/unixODBC-2.3.14 --disable-gui
make
make install
.bash_profile Environment Variable Setup
To properly recognize unixODBC and the Tibero ODBC Driver,
set the following environment variables in the DB connection userโs .bash_profile.
vi ~/.bash_profile# Tibero ENV
export TB_HOME=/home/test7/tibero7
export TB_SID=test7
export TB_PROF_DIR=$TB_HOME/bin/prof
# unixODBC ENV
export ODBC_HOME=/home/test7/unixodbc/install/unixODBC-2.3.14
export ODBCSYSINI=$ODBC_HOME/etc
export ODBCINI=$ODBC_HOME/etc/odbc.ini
export ODBCINSTINI=odbcinst.ini
# PATH / LIB
export PATH=$TB_HOME/bin:$TB_HOME/client/bin:$ODBC_HOME/bin:$PATH
export LD_LIBRARY_PATH=$TB_HOME/lib:$TB_HOME/client/lib:$ODBC_HOME/lib:/usr/lib64:$LD_LIBRARY_PATHApply and verify settings:
source ~/.bash_profile
env | egrep 'TB_HOME|ODBC_HOME|ODBCINI|ODBCINSTINI|ODBCSYSINI'Verify Installation
$ODBC_HOME/bin/isql --version
$ODBC_HOME/bin/odbcinst -j
ODBC Driver and DSN Configuration
odbcinst.ini (Register Driver)
vi $ODBC_HOME/etc/odbcinst.ini
[Tibero]
Description = Tibero ODBC Driver
Driver = /home/test7/tibero7/client/lib/libtbodbc.so
FileUsage = 1odbc.ini (Register DSN)
vi $ODBC_HOME/etc/odbc.ini
[TIBERO7]
Description = Tibero7 ODBC Test
Driver = Tibero
ServerName = 127.0.0.1
Port = 5555
SID = test7
User = tibero
Password = tmaxCheck DSN
$ODBC_HOME/bin/odbcinst -q -d
$ODBC_HOME/bin/odbcinst -q -s
Pre-Verification of ODBC Connection (isql)
$ODBC_HOME/bin/isql -v TIBERO7 tibero tmaxIf connected successfully, the following prompt appears:
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| echo [string] |
| quit |
| |
+---------------------------------------+
SQL>
PHP 8.1 Installation (Including ODBC)
Download PHP Source
wget https://www.php.net/distributions/php-8.1.29.tar.gz
tar -xzvf php-8.1.29.tar.gz
cd php-8.1.29Configure and Build
./buildconf --force
./configure --prefix=/home/test7/php81 --with-unixODBC=$ODBC_HOME --with-odbcver=0x0352 --disable-all --enable-cli --enable-odbc
--with-unixODBC : Use external unixODBC library
--with-odbcver : Compile based on ODBC 3.52 specification
--disable-all : Build with minimal modules for CLI testing
--enable-cli : Generate CLI-only PHP binary
make
make installVerify ODBC Module
/home/test7/php81/bin/php -m | grep -i odbc
PHP ODBC Integration Test
Test Script (test.php)
The test.php file can be created in any directory,
but it must be executed by the user account that recognizes the ODBC configuration file (odbc.ini).
vi /home/test7/unixodbc/install/unixODBC-2.3.14/etc/test.php
<?php
$dsn = "TIBERO7";
$user = "tibero";
$pass = "tmax";
$conn = odbc_connect($dsn, $user, $pass);
if (!$conn) {
echo "CONNECT FAIL: " . odbc_errormsg() . PHP_EOL;
exit(1);
}
echo "CONNECT OK\n";
$rs = odbc_exec($conn, "select sysdate from dual");
while ($row = odbc_fetch_array($rs)) {
print_r($row);
}
odbc_close($conn);
echo "DONE\n";
?>Run
/home/test7/php81/bin/php test.phpExecution Result
CONNECT OK
Array
(
[SYSDATE] => 2025/12/15
)
DONE
Verification Results
PHP 8.1 ODBC module loaded successfully
unixODBC โ Tibero ODBC Driver integration confirmed
Tibero7 DB connection and SQL execution successful
Notes
PHP was installed by compiling from source and may differ from the distributed package.
Setting ODBC environment variables (
ODBCSYSINI,ODBCINI) is important.You can add and test DSNs for other Tibero databases on the same server.