How to connect PHP and oracle_php tutorials without using the OCI8 interface

Source: Internet
Author: User
As the size of the site expands, MySQL is clearly unable to meet the needs of many sites that are
In the case of large database Oracle, how to use PHP to access Oracle becomes increasingly important.
I've been talking about how I did it from a simple ierp system I wrote in the official PHP manual.
In general, or most people use Oracle8 call-interface (OCI8) to connect to a database,
I present here the Oracle functions that use PHP directly without using the OCI8 interface to connect to the database and process the data.

Attention:
PHP.ini in the configuration to be removed; Extension=php_oracle.dll before the semicolon is
Extension=php_oracle.dll

1, connecting the database

Use Ora_logon () or Ora_plogon () to connect to the database
Ora_plogon function is similar to Ora_logon, but Ora_plogon open 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 the manager is the user password

2, open cursor
$cursor = Ora_open ($handle);

3, parsing syntax and executing instructions
$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 might be doing a delete or INSERT statement without the steps to get the 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);


http://www.bkjia.com/PHPjc/532517.html www.bkjia.com true http://www.bkjia.com/PHPjc/532517.html techarticle as the size of the site expands, MySQL is clearly unable to meet demand, and it becomes increasingly important to use PHP to access Oracle in cases where many sites are using large database Oracle. I am from ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.