当前位置:网站首页>OpenSUSE environment PHP connection Oracle

OpenSUSE environment PHP connection Oracle

2022-06-25 03:48:00 Diving rice awn

  1. Good configuration oracle client
 zypper in apache2 #  install apache2, Please see the opensuse wiki
 zypper in apache2-mod_php8 #  install apache Integrate php, See opensuse wiki
 zypper in php8-devel #  Not installed not found phpize
 C_INCLUDE_PATH=/usr/lib/oracle/21/client64 pecl install oci8 #  Please refer to your own address here oracle home Address 
 #  In the next prompt box, type 
 instantclient,/usr/lib/oracle/21/client64

After success, press the prompt to change php.ini,extension=oci8.so( Here to rewrite ,php.ini Yes, but not behind .so, Be careful )

Build process completed successfully
Installing '/usr/lib64/php8/extensions/oci8.so'
install ok: channel://pecl.php.net/oci8-3.2.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini

Test the connection :

#  Variables switch by themselves , Then if the Chinese characters come out in disorder , Please pay attention to the following UTF8( This is not writing utf-8, Be careful )
$conn = oci_connect($username,$password,$sid,'UTF8');
    $stid = oci_parse($conn,$sql);
    oci_execute($stid);
    echo "<table>\n";
    while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
    
        echo "<tr>\n";
        foreach ($row as $item) {
    
            echo " <td>".($item !== null ? htmlentities($item, ENT_QUOTES) : " ")."</td>\n";
        }
        echo "</tr>\n";
    }
    echo "</table>\n";
原网站

版权声明
本文为[Diving rice awn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210538445637.html

随机推荐