laravel 操作 oracle数据库

windows下 oracle扩展

  • 找到php.ini打开php oci8扩展
;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client

php5.6.9下为

;extension=php_oci8.dll      ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll  ; Use with Oracle 11gR2 Instant Client
  • 下载 Oracle Instant Client

Oracle Instant Client下载地址
https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html

  • 设置系统环境变量并重启电脑

Linux下PHP7 oracle扩展

  • 下载 Oracle Instant Client

参照上边的下载地址选择对应安装包

rpm -ivh oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
rpm -ivh oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
  • 安装扩展

https://pecl.php.net/package/oci8
找到对应PHP版本的oci8扩展包

wget https://pecl.php.net/get/oci8-2.2.0.tgz
tar -xzvf oci8-2.2.0.tgz
/usr/local/webserver/php-7/bin/phpize
./configure --with-php-config=/usr/local/webserver/php-7/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/18.3/client64/lib/
make && make install
#vim php.ini找到对应extension 添加 extension=oci8.so 重启php-fpm

Laravel支持oracle数据库操作

使用composer扩展包 yajra/laravel-oci8
https://packagist.org/packages/yajra/laravel-oci8#v5.7.2

参考资料

猜你喜欢

转载自blog.csdn.net/weixin_33716941/article/details/87171567