<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>danielcolomb.com &#187; php</title>
	<atom:link href="http://www.danielcolomb.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danielcolomb.com</link>
	<description>rantings of a technophile</description>
	<lastBuildDate>Wed, 05 May 2010 02:30:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Oracle and PHP</title>
		<link>http://www.danielcolomb.com/2008/12/29/oracle-and-php/</link>
		<comments>http://www.danielcolomb.com/2008/12/29/oracle-and-php/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 18:17:28 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[set up]]></category>

		<guid isPermaLink="false">http://www.danielcolomb.com/?p=282</guid>
		<description><![CDATA[<p>So a few weeks ago i talked about how confusing Oracle and its&#8217; clients can be. While i still think the lack of simple documentation, and confusing download layout are very annoying, I&#8217;ve begun to understand how things work. Well.. kind of. And by &#8220;kind of&#8221;, I totally mean, i&#8217;m still pretty lost. At least now [...]]]></description>
			<content:encoded><![CDATA[<p>So a few weeks ago i talked about how <a href="http://www.danielcolomb.com/2008/11/25/oracle-why-just-why/" target="_blank">confusing Oracle</a> and its&#8217; clients can be. While i still think the lack of simple documentation, and confusing download layout are very annoying, I&#8217;ve begun to understand how things work. Well.. kind of. And by &#8220;kind of&#8221;, I totally mean, i&#8217;m still pretty lost. At least now i have a dim candle lighting the dark cavern I&#8217;m in.</p>
<p>I&#8217;m going to go step by step on how I got my WAMP (Windows, Apache, MySQL, PHP) Stack to also incorporate Oracle support. I&#8217;m assuming you already have a properly working Apache Webserver running with PHP enabled.</p>
<p><span style="text-decoration: underline;"><strong>PHP and the Oracle: A layman&#8217;s story</strong></span></p>
<p><strong>1)</strong> Uninstall any existing copy of the Oracle Client, unless it&#8217;s needed for other functionality. (We had an Oracle 9i Client at work, which was installed on many of the machines, but wasn&#8217;t needed in this case, and i couldn&#8217;t find any documentation online to get it to work with PHP&#8230;)</p>
<p><strong>2)</strong> Install the <a href="http://www.oracle.com/technology/software/tech/oci/instantclient/index.html" target="_blank">Instant Client</a> provided at the Oracle site. Make sure to choose the proper options, like your architecture, and whatever client you wish; i used &#8216;Instant Client Package &#8211; Basic&#8217; &#8212; because it stated it had all the required files for OCI connections, which is what i was using for my Oracle&lt;-&gt;Webserver calls.</p>
<p><strong>3)</strong> Edit your PATH Environment Variable. Add the directory to where you installed your instant client to the end. For Example, I installed to C:\oracle\instant_client, so i added &#8216;;C:\oracle\instant_client&#8217; &#8212; note the preceding &#8216;;&#8217;, this is needed if the end of your PATH already doesn&#8217;t have it. It&#8217;s the delimiter for the different directories added to your path.</p>
<p>You only need to add the main directory to which you installed, the php_oci extension will look for the dll&#8217;s in that main directory. Also make sure you don&#8217;t have the trailing &#8216;\&#8217; at the end. Depending on your windows installation it might not like that&#8230; &#8212; Windows can be so picky when it want.. <img src='http://www.danielcolomb.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><strong>4)</strong> Open your php.ini file and uncomment the line &#8216;;extension=php_oci8.dll&#8217; &#8212; uncomment means take off the &#8216;;&#8217; before the &#8216;extension=&#8217;.</p>
<p><strong>5)</strong> Create a phpinfo file. Something simple like this will work.</p>
<p><code>&lt;?php<br />
phpinfo();<br />
?&gt;<br />
</code></p>
<p>Once you&#8217;ve created the file and placed it on your webserver, browse to it. Scroll through, if it&#8217;s properly set up, you should see a category called &#8220;oci8&#8243;.  If not, make sure that anywhere where PATH is referenced, it shows your updated PATH &#8212; with your Instant Client Directory added. If it&#8217;s not there you may need to restart your Windows server. I was having issues with my PATH properly updating and was forced to do this.</p>
<p>Setup should be complete now.  Next is testing.</p>
<p><strong>6)</strong> Try to connect to your Oracle server. I personally use the OCI. Something like this should work:</p>
<p><code>&lt;?php<br />
$user = "username";<br />
$pw = "password";<br />
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = your.host.domain)(PORT = 1521)))(CONNECT_DATA=(SID=yourSID)))";<br />
$conn = ocilogon($user,$pw,$db);<br />
?&gt;</code></p>
<p>You don&#8217;t need a TNSNAMES.ORA, but can use one (as far as i know). To use one just create the file in the root of the instant client installation.<br />
If you don&#8217;t get a fatal error you should be good to go now. You now have the functionality to connect to Oracle databases.  I&#8217;d love to hear how others have done this. Maybe there&#8217;s a better way to do it than what i did.</p>
<p>Some good resources for PHP and Oracle:<br />
<a href="http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/index.html" target="_blank">http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/index.html</a><br />
<a href="http://www.orafaq.com/wiki/PHP_FAQ" target="_blank">http://www.orafaq.com/wiki/PHP_FAQ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielcolomb.com/2008/12/29/oracle-and-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
