{"id":1352,"date":"2018-01-19T19:22:44","date_gmt":"2018-01-19T19:22:44","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/oracle-with-php-a-developers-view-page-2\/"},"modified":"2018-01-19T19:24:43","modified_gmt":"2018-01-19T19:24:43","slug":"oracle-with-php-a-developers-view-page-2","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/oracle-with-php-a-developers-view-page-2\/","title":{"rendered":"Oracle with PHP: a Developers View Page 2"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By Rajeev Ranjan Rakesh<\/div>\n<div class=\"\">on October 17, 2008<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<div class=\"example\">\n<code><\/p>\n<pre>\n$conn = oci_connect($dbuser,$dbpassword, ??CONN_STRING??);\n\n$sql = \"SELECT??*??FROM??EMPLOYEE_TABLE\";\n<\/pre>\n<p>    <\/code>\n    <\/div>\n<div class=\"articlePara\">\nHere $sql stores the sql statement which is to be executed:\n    <\/div>\n<div class=\"example\">\n<code><\/p>\n<pre>\n$stmt??=??oci_parse($conn,??$sql);\n<\/pre>\n<p>    <\/code>\n    <\/div>\n<div class=\"articlePara\">\noci_parse() function prepares the statement for execution. It takes the connection identifier and the sql query as a parameter and returns a statement handler.\n    <\/div>\n<div class=\"example\">\n<code><\/p>\n<pre>\noci_execute($stmt,??OCI_DEFAULT);\n<\/pre>\n<p>    <\/code>\n    <\/div>\n<div class=\"articlePara\">\noci_execute() function executes the parsed statement. This function can have two parameters. The first one is the valid OCI statement identifier and the second one is the mode (option parameter). By default OCI_COMMIT_ON_SUCCESS.\n<\/div>\n<div class=\"articlePara\">\nNote: If you don&#8217;t want statements to be committed automatically, you should specify OCI_DEFAULT as mode.\n    <\/div>\n<div class=\"example\">\n<code><\/p>\n<pre>\nwhile($result =oci_fetch_array($stmt)) {\t\n\techo $result[??EMPLOYEE_NAME??] . \"&lt;br&gt;\";\t\n}\n<\/pre>\n<p>    <\/code>\n    <\/div>\n<div class=\"articlePara\">\nThe statement above stores the result of oci_fetch_array($stmt) in the variable $result. oci_fetch_array() returns an array. The second parameter is optional for this function and can have values like OCI_BOTH, OCI_ASSOC, OCI_NUM depending on the type of array that is required. Once the array is returned and stored in the variable $result, we display the Employee name from the selected columns.\n    <\/div>\n<div class=\"example\">\n<code><\/p>\n<pre>\noci_close($conn);\n    <\/pre>\n<p>    <\/code>\n    <\/div>\n<div class=\"articlePara\">\nThis function is used to close the connection to the Oracle database.\n<\/div>\n<div class=\"articlePara\">\nThis completes the explanation of the sample code that is used to connect and perform operations on the Oracle database using PHP??s ADOdb abstract library.\n    <\/div>\n<div class=\"articlePara\">\nJoin us next week when we delve into the ADOdb library and continue our discussion on using Oracle and PHP!\n    <\/div>\n<p><\/p>\n<\/div>\n<p><\/p>\n<div style=\"float: left; padding:15px; color:#17AAF3\">\n<div style=\"float:left; padding:2px;\"><a class=\"paginationPageLink\" href=\"rajeevrakesh20081016.html\">\u00ab Previous Page<\/a><\/div>\n<div style=\"float:left; padding:2px 4px 2px 4px;\"><a class=\"pageNumber\" href=\"rajeevrakesh20081016.html\">1<\/a> <\/div>\n<div style=\"float:left; font-size:16px; color:#FF7A22; padding:2px 2px 2px 2px; \">| <\/div>\n<div style=\"background-color:#B6E5FC; font-size:16px; margin-top:1px; padding:1px 4px 1px 4px; color:#000; font-style:bold; float:left;\">2<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This article is for the developer who wants to use the PHP scripting language and an Oracle database to develop their application. There are<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1352","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=1352"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1352\/revisions"}],"predecessor-version":[{"id":3235,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/1352\/revisions\/3235"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=1352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=1352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=1352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}