Home Backend Development PHP Tutorial How to connect PHP and Oracle without using OCI8 interface_PHP tutorial

How to connect PHP and Oracle without using OCI8 interface_PHP tutorial

Jul 13, 2016 pm 05:21 PM
mysql oracle php No cannot use and how interface satisfy of website scale connect along with


With the expansion of website scale, MySql obviously cannot meet the demand. With many websites
using large database Oracle, how to use PHP to access Oracle has become more and more important.
I will talk about how I did it from a simple iERP system I wrote, which is also explained in the official PHP manual.
Generally speaking, most people use Oracle8 Call-Interface (OCI8) to connect to the database.
Here I will introduce not using the OCI8 interface but directly using PHP's Oracle function to connect to the database and process data.

Note:
Remove the semicolon before ;extension=php_oracle.dll in the php.ini configuration, that is,
extension=php_oracle.dll

1, Connect to database

Use ora_logon() or ora_plogon() to connect to the database
ora_plogon function is similar to ora_logon, except that ora_plogon opens a long-term connection with Oracle
until the web service stops

$handle = ora_plogon("system@localhost", "manager") or die;
"system@localhost" where localhost is the oracle SID name, system is the user name, and manager is the user password

2, open the cursor
$cursor = ora_open($handle);

3, analyze the syntax and execute the command
$query = "select count(*) from area where areacode = $addcode";
ora_parse($cursor, $query) or die;
ora_exec( $cursor);

4, Get data
if(ora_fetch($cursor))
$datacount = ora_getcolumn($cursor, 0);
5, Close the cursor
ora_close($cursor);

Of course, you may be executing a delete or insert statement and there are no steps to obtain data, such as:
INSERT: (insert)

$handle = ora_plogon("system@localhost", "manager") or die;
ora_commiton($handle);
$cursor = ora_open($handle);
$query = "insert into area(areacode,areaname) values($addcode,$addname)";
ora_parse($cursor, $query) or die;
ora_exec($cursor);
ora_close($cursor);

DELETE: (delete)

$handle = ora_plogon("system@localhost", "manager") or die;
$cursor = ora_open($handle);
ora_commiton($handle);
$query = "delete from area where areacode in (222,444)" ;
ora_parse($cursor, $query) or die;
ora_exec($cursor);
ora_close($cursor);


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532517.htmlTechArticleAs the scale of the website expands, MySql obviously cannot meet the demand. When many websites use large database Oracle , how to use PHP to access Oracle has become more and more important. I started with...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

CakePHP Date and Time

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

CakePHP Project Configuration

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

CakePHP File upload

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

CakePHP Routing

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

Discuss CakePHP

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP Quick Guide

See all articles