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 ...