Connecting to Oracle via php
On May 25,2022 by Tom RoutleyOracle database is a useful database server which can be connected through a PHP script. Web servers using SQLPlus can access the Oracle server through this process. Servers based on the Oracle 8i module can normally be connected. For PHP to interact with the Oracle database, the PHP scripting language must be assembled to this extension module. On the Windows OS, the php.ini file must be edited before the process is accomplished.
Intro
Below is an article based on an example of connection to an Oracle database through a php script. However it is not designed to configure your oracle server and oracle client. It ensures that you can access your oracle server from the web server using the SQLPlus.
We can normally connect to a server based on Oracle 8i.
Requirements
It is essential to assemble PHP with Oracle8i module. Under windows, it is crucial to the php.ini to include the line extension=php_oci8.dll
Example of code
$c1 = ocilogon("scott", "tiger", $db); $c2 = ocilogon("scott", "tiger", $db); function create_table($conn) $stmt = ociparse($conn, "create table scott.hallo (test varchar2(64))"); ociexecute($stmt); echo $conn . " created table
"; function drop_table($conn) $stmt = ociparse($conn, "drop table scott.hallo"); ociexecute($stmt); echo $conn . " dropped table
"; function insert_data($conn) $stmt = ociparse($conn, "insert into scott.hallo values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))"); ociexecute($stmt, OCI_DEFAULT); echo $conn . " inserted hallo
";
This is one of the easiest way to access Oracle amongst others.
Article Recommendations
Latest articles
Popular Articles
Archives
- November 2024
- October 2024
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
- December 2023
- November 2023
- October 2023
- September 2023
- August 2023
- July 2023
- June 2023
- May 2023
- April 2023
- March 2023
- February 2023
- January 2023
- December 2022
- November 2022
- October 2022
- September 2022
- August 2022
- July 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
- September 2021
- August 2021
- July 2021
- January 2021
Leave a Reply