Oracle
With the expansion of the site, MySQL is clearly unable to meet the demand, in many sites are
With large database Oracle, how to use PHP to access Oracle is becoming more important.
I've talked about how I did it from a simple ierp system I wrote, as explained in the official PHP manual.
In general or most people use Oracle8 call-interface (OCI8) to connect to a database,
Here I introduce Oracle functions that use PHP directly without using the OCI8 interface to connect to the database and process the data.
Attention:
PHP.ini configuration to be removed; the semicolon before Extension=php_oracle.dll is
Extension=php_oracle.dll
1, connecting to the database
Use Ora_logon () or Ora_plogon () to connect to the database
The Ora_plogon function is similar to Ora_logon, except that the 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 the manager is the user password
2, open cursor
$cursor = Ora_open ($handle);
3, parsing grammar and executing instructions
$query = "SELECT count (*) from the area where AreaCode = ' $addcode '";
Ora_parse ($cursor, $query) or die;
Ora_exec ($cursor);
4, get the data
if (Ora_fetch ($cursor))
$datacount = Ora_getcolumn ($cursor, 0);
5, closing the cursor
Ora_close ($cursor);
Of course, you might be able to execute the DELETE or INSERT statement does not exist steps to get 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);