
1 把两个oracle实例包解压
oracle官网下载地址
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
➜ 两个oracle实例包 tree
├── instantclient-basic-macos.x64-19.8.0.0.0dbru.zip
└── instantclient-sdk-macos.x64-19.8.0.0.0dbru.zip
2 拷贝到/Users/tanjian/tanjian_env/instantclient_19_8
3 配置环境变量
export ORACLE_HOME=/Users/tanjian/tanjian_env/instantclient_19_8
➜ ~ cat .bash_profile
# for color
export CLICOLOR=1
# \h:\W \u\$
#export PS1='\[\033[01;33m\]\u@\h\[\033[01;31m\] \W\$\[\033[00m\] '
# grep
alias grep='grep --color=always'
export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
export SVN_EDITOR=vim
export ORACLE_HOME=/Users/tanjian/tanjian_env/instantclient_19_8
4 php扩展目录添加oci.so文件
/usr/local/lib/php/pecl/20170718
➜ 20170718
➜ 20170718 cp ~/oci8-2.2.0/.libs/oci8.so ./
cp: ./oci8.so: Permission denied
➜ 20170718 sudo cp ~/oci8-2.2.0/.libs/oci8.so ./
phpinf()确认
oci8
OCI8 Support enabled
OCI8 DTrace Support disabled
OCI8 Version 2.2.0
Oracle Run-time Client Library Version 19.8.0.0.0
➜ 20170718 php -m|grep oci
PHP Warning: Module 'mongodb' already loaded in Unknown on line 0
oci8
5 PHP代码
/**
* php7.1 连接本地oracel(docker)代码
*/
$username = 'system';//helowin
$password = 'oracle';
$str = '127.0.0.1/helowin';
$conn = oci_connect($username, $password, $str);
$sql = "select IDCARD,TELEPHONE from LOCAL_DSFJK.V_LANGANXINLI";
$stid = oci_parse($conn,$sql);
oci_execute($stid,OCI_DEFAULT);
while($row=oci_fetch_array($stid))
{
dd($row);
echo $row['IDCARD']."<br/>";
}
//array(4) {
// [0]=>
// string(18) "330202194X"
// ["IDCARD"]=>
// string(18) "330202194X"
// [1]=>
// string(11) "15205822115"
// ["TELEPHONE"]=>
// string(11) "15205822115"
//}
说明:
1开发环境为:macpro、本地docker安装的oracle11g、php7.2。
2 有交流需求可加我微信:wngzs2022




