<?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>MacLochlainns Weblog &#187; PHP</title>
	<atom:link href="http://blog.mclaughlinsoftware.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mclaughlinsoftware.com</link>
	<description>Michael McLaughlin's Technical Blog</description>
	<lastBuildDate>Wed, 28 Jul 2010 00:02:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Nice &#8220;how-to&#8221; install OPAL on Ubuntu 8 Server</title>
		<link>http://blog.mclaughlinsoftware.com/2008/07/20/nice-how-to-install-opal-on-ubuntu-8-server/</link>
		<comments>http://blog.mclaughlinsoftware.com/2008/07/20/nice-how-to-install-opal-on-ubuntu-8-server/#comments</comments>
		<pubDate>Sun, 20 Jul 2008 21:16:09 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OCI8]]></category>
		<category><![CDATA[OPAL]]></category>
		<category><![CDATA[Oracle Client]]></category>
		<category><![CDATA[Ubuntu Server]]></category>

		<guid isPermaLink="false">http://maclochlainn.wordpress.com/?p=119</guid>
		<description><![CDATA[I noticed that somebody posted instructions and some scripts to install the OPAL (Oracle, Perl/PHP, Apache, Linux) in the OTN forum. I haven&#8217;t had a chance to run though it yet. Thought I&#8217;d point you to it directly. If you want the forum, go here. He&#8217;d like feedback in the forum.]]></description>
			<content:encoded><![CDATA[<p>I noticed that somebody posted instructions and some scripts to install the OPAL (Oracle, Perl/PHP, Apache, Linux) in the OTN forum. I haven&#8217;t had a chance to run though it yet. Thought I&#8217;d point you <a title="Insall OPAL on Ubuntu" href="http://www.danilovizzarro.it/?p=7" target="_blank">to it directly</a>. If you want the forum, go <a title="Forum Posting of Install Steps" href="http://forums.oracle.com/forums/thread.jspa?threadID=681232&amp;tstart=0" target="_blank">here</a>. He&#8217;d like feedback in the forum.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2008/07/20/nice-how-to-install-opal-on-ubuntu-8-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP code to read a PL/SQL reference cursor</title>
		<link>http://blog.mclaughlinsoftware.com/2008/05/12/php-code-to-read-a-plsql-reference-cursor/</link>
		<comments>http://blog.mclaughlinsoftware.com/2008/05/12/php-code-to-read-a-plsql-reference-cursor/#comments</comments>
		<pubDate>Mon, 12 May 2008 05:17:34 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[pl/sql]]></category>
		<category><![CDATA[reference cursor]]></category>

		<guid isPermaLink="false">http://maclochlainn.wordpress.com/?p=15</guid>
		<description><![CDATA[The following demonstrates how to read a PL/SQL reference cursor in a PHP program. The reference cursor function is defined in the Pipelined Functions &#38; PL/SQL Tables blog page. I&#8217;ve commented it to the hilt for those new to PHP. The reference cursor maintains a separate connection to the database to access the reference cursor. You also use the [...]]]></description>
			<content:encoded><![CDATA[<p>The following demonstrates how to read a PL/SQL reference cursor in a PHP program. The reference cursor function is defined in the <a title="Pipelined Functions &amp; PL/SQL Tables" href="http://blog.mclaughlinsoftware.com/pipelined-functions-plsql-tables/" target="_blank">Pipelined Functions &amp; PL/SQL Tables</a> blog page. I&#8217;ve commented it to the hilt for those new to PHP.</p>
<p>The reference cursor maintains a separate connection to the database to access the reference cursor. You also use the <code>oci_fetch_assoc()</code> function to get the data. That <code>strip_special_characters()</code> function lets you format your call to the PL/SQL program and remove non-parsing line returns and tabs before running the <code>oci_parse()</code> function.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #666666; font-style: italic;">// Return successful attempt to connect to the database.</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span>oci_connect<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;plsql&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;plsql&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;orcl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Declare input variables.</span>
    <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'table'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'table'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ITEM'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$column</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$column</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ITEM_TYPE'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Declare a PL/SQL execution command.</span>
    <span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;BEGIN
              :return_cursor := get_common_cursor(:table,:column);
            END;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Strip special characters to avoid ORA-06550 and PLS-00103 errors.</span>
    <span style="color: #000088;">$stmt</span> <span style="color: #339933;">=</span> strip_special_characters<span style="color: #009900;">&#40;</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Parse a query through the connection.</span>
    <span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> oci_parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span><span style="color: #000088;">$stmt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Declare a return cursor for the connection.</span>
    <span style="color: #000088;">$rc</span> <span style="color: #339933;">=</span> oci_new_cursor<span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Bind PHP variables to the OCI input or in mode variables.</span>
    oci_bind_by_name<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #0000ff;">':table'</span><span style="color: #339933;">,</span><span style="color: #000088;">$table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    oci_bind_by_name<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #0000ff;">':column'</span><span style="color: #339933;">,</span><span style="color: #000088;">$column</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Bind PHP variables to the OCI output or in/out mode variable.</span>
    oci_bind_by_name<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">,</span><span style="color: #0000ff;">':return_cursor'</span><span style="color: #339933;">,</span><span style="color: #000088;">$rc</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>OCI_B_CURSOR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Execute the PL/SQL statement &amp;amp; reference cursor.</span>
    oci_execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    oci_execute<span style="color: #009900;">&#40;</span><span style="color: #000088;">$rc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Print the table header with known labels.</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;table border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Set dynamic labels control variable true.</span>
    <span style="color: #000088;">$label</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Read the contents of the reference cursor.</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> oci_fetch_assoc<span style="color: #009900;">&#40;</span><span style="color: #000088;">$rc</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">// Declare header and data variables.</span>
      <span style="color: #000088;">$header</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Read the reference cursor into a table.</span>
      <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$column</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Capture labels for the first row.</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$label</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$header</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;td class=&quot;e&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/td&gt;'</span><span style="color: #339933;">;</span>
          <span style="color: #000088;">$data</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;td class=&quot;v&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$column</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/td&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span>
          <span style="color: #000088;">$data</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&lt;td class=v&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$column</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/td&gt;'</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Print the header row once.</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$label</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$header</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$label</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #000088;">$label</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// Print the data rows.</span>
      <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;tr&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$data</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/tr&gt;'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Print the HTML table close.</span>
    <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'&lt;/table&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Disconnect from database.</span>
    oci_close<span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Assign the OCI error and format double and single quotes.</span>
    <span style="color: #000088;">$errorMessage</span> <span style="color: #339933;">=</span> oci_error<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errorMessage</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Strip special characters, like carriage or line returns and tabs.</span>
  <span style="color: #000000; font-weight: bold;">function</span> strip_special_characters<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$out</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
          <span style="color: #009900;">&#40;</span><span style="color: #990000;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #000088;">$out</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Return character only strings.</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$out</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2008/05/12/php-code-to-read-a-plsql-reference-cursor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oracle PHP/AJAX Framework</title>
		<link>http://blog.mclaughlinsoftware.com/2008/05/04/oracle-phpajax-framework/</link>
		<comments>http://blog.mclaughlinsoftware.com/2008/05/04/oracle-phpajax-framework/#comments</comments>
		<pubDate>Sun, 04 May 2008 18:32:47 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[quickconnect]]></category>

		<guid isPermaLink="false">http://maclochlainn.wordpress.com/?p=11</guid>
		<description><![CDATA[While writing Oracle Database 11g PL/SQL Programming book last year, I collaborated with Lee Barney on a PHP/AJAX framework. Our Oracle Database AJAX &#38; PHP Web Application Development book covers the framework. You can find a new and improved version at SourceForge.net. Lee maintains the code and continues to improve it. I&#8217;m sure he&#8217;d welcome suggestions [...]]]></description>
			<content:encoded><![CDATA[<p>While writing <a title="Oracle Database 11g PL/SQL Programming" href="http://www.amazon.com/Oracle-Database-11g-Programming-Press/dp/0071494456/ref=pd_ts_b_1?ie=UTF8&amp;s=books" target="_blank">Oracle Database 11<em>g</em> PL/SQL Programming</a> book last year, I collaborated with Lee Barney on a PHP/AJAX framework. Our <a title="Oracle Database AJAX &amp; PHP Web Application Development" href="http://www.amazon.com/Oracle-Database-Application-Development-Press/dp/0071502777/ref=sr_1_7?ie=UTF8&amp;s=books&amp;qid=1209934862&amp;sr=1-7" target="_blank">Oracle Database AJAX &amp; PHP Web Application</a> Development book covers the framework. You can find a new and improved version at <a href="http://sourceforge.net/projects/quickconnect" target="_blank"><span style="color:#800080;">SourceForge.net</span></a>. Lee maintains the code and continues to improve it. I&#8217;m sure he&#8217;d welcome suggestions and collaboration. We see it as very useful to AJAX web development, and to the Open Source community.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2008/05/04/oracle-phpajax-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
