• win7 php连接远程oracle


    <?php
    /*
    先下载oracle客户端
    下载地址
    http://www.oracle.com/technetwork/topics/winx64soft-089540.html
    下载如下三个版本
    instantclient-basic-win64-10.2.0.5.zip
    instantclient-sqlplus-win64-10.2.0.5.zip
    instantclient-odbc-win64-10.2.0.5.zip
    
    
    
    另下载php Oracle驱动,下载地址 https://windows.php.net/downloads/pecl/releases/oci8/2.0.10/
    这里版本是
    php_oci8-2.0.10-5.5-ts-vc11-x64.zip
    将其中内容全部解压缩到php编译文件目录下的 ext 文件夹里
    这里是
    D:ApacheServerphpext
    
    
    
    将三个压缩包解压缩到一个默认文件夹 instantclient_10_2 下
    这里instantclient_10_2 放在了 Navicat Premium 安装目录下,位置为
    D:ApacheServerNavicat Premiuminstantclient_10_2
    
    修改环境变量
    全部在系统变量中
    修改如下
    新增
    变量名
    NLS_LANG
    变量值
    SIMPLIFIED CHINESE_CHINA.ZHS16GBK
    
    变量名
    ORACLE_HOME
    变量值
    D:ApacheServerNavicat Premiuminstantclient_10_2
    
    变量名
    TNS_ADMIN
    变量值
    D:ApacheServerNavicat Premiuminstantclient_10_2
    
    修改
    变量名
    Path
    结尾处新增
    ;D:ApacheServerNavicat Premiuminstantclient_10_2
    注意和之前值之间有个 ;
    
    
    
    
    
    
    
    
    
    
    instantclient_10_2 目录下新建 TNSNAME.ORA,这里是D:ApacheServerNavicat Premiuminstantclient_10_2TNSNAME.ORA
    内容如下
    ================================以下TNSNAME.ORA内容==============================
    SHTSDB =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 45.97.194.92)(PORT = 1521))
        (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = SHTSDB)
      )
    )
    
    EXTPROC_CONNECTION_DATA =
      (DESCRIPTION =
        (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
        )
      (CONNECT_DATA =
        (SID = PLSExtProc)
        (PRESENTATION = RO)
      )
    )
    ================================以上TNSNAME.ORA内容==============================
    SHTSDB 是Oracle实例名(库名,SID名),服务器IP 45.97.194.92,端口号1521
    
    
    
    
    
    
    启动命令行
    d:
    cd D:ApacheServerNavicat Premiuminstantclient_10_2
    odbc_install.exe
    
    
    
    最后重启电脑
    
    
    
    
    输入如下代码测试即可
    新建index.php页面,输入如下内容
    */
    phpinfo();exit;
    $db_server = "45.97.194.92";
    $db_user = "YIMAI";
    $db_pass = "YIMAI";
    $db_sid = "SHTSDB";
    $dbconn=OCILogon($db_user,$db_pass,"(DEscriptION=(ADDRESS=(PROTOCOL=TCP)(HOST=45.97.194.92)(PORT= 1521))(CONNECT_DATA =(SID=$db_sid)))"); 
    if($dbconn!=false) 
    {
        echo "连接"; 
        echo "DB服务器:".$db_server;
        echo "用户:".$db_user;
        echo "口令:".$db_pass;
        echo "SID:".$db_sid;
        echo "成功
    ";
        if(OCILogOff($dbconn)==true) 
        { 
            echo "关闭连接成功!";
        } 
    } 
    else 
    { 
        echo "连接失败"; 
    } 
    ?>
  • 相关阅读:
    Android获取屏幕分辨率及DisplayMetrics简介(轉)
    程序员技术练级攻略
    CSDN精选iPhone开发博客
    Java中访问权限修饰符public protected 缺省默认 private的用法总结(转)
    Java中abstract class 和 interface 的解释和他们的异同点(转)
    Code Project精彩系列(转)
    java中重载与重写的区别
    HDU 1024 Max Sum Plus Plus(动态规划,给定一个数组,求其分成m个不相交子段和最大值的问题)
    Triple ACM HDU 3908 (数学题,找多少种组合)
    ACM POJ 1015 Jury Compromise(陪审团的人选,动态规划题,难)
  • 原文地址:https://www.cnblogs.com/dreamhome/p/8878263.html
Copyright © 2020-2023  润新知