<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: oci_bind_by_name maxlength is not so optional</title>
	<atom:link href="http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/feed/" rel="self" type="application/rss+xml" />
	<link>http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/</link>
	<description>web, money and etc.</description>
	<lastBuildDate>Wed, 22 Dec 2010 21:08:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: matt</title>
		<link>http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/comment-page-1/#comment-5965</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Tue, 26 Aug 2008 03:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://livebookmark.net/journal/?p=168#comment-5965</guid>
		<description>i hate to spam your site, but i forgot to point out the very important piece. it has nothing to do with the column length, however it has everything to do with the way in which you reference the bindvar from within the loop. notice how i reference it $bindvars[$statement_bind] and not by $val.

this is true for foreach loops as well. in fact foreach loops are faster than the while list.


right

foreach($bindvars as $statement_bind =&gt; $variable_bind)
{ 
    if(! oci_bind_by_name($stmtid, &#039;:&#039; . $statement_bind, $bindvars[$statement_bind], -1))
    {
        //Fail
    }
}  




wrong


foreach($bindvars as $statement_bind =&gt; $variable_bind)
{ 
    if(! oci_bind_by_name($stmtid, &#039;:&#039; . $statement_bind, $variable_bind, -1))
    {
        //Fail
    }
}</description>
		<content:encoded><![CDATA[<p>i hate to spam your site, but i forgot to point out the very important piece. it has nothing to do with the column length, however it has everything to do with the way in which you reference the bindvar from within the loop. notice how i reference it $bindvars[$statement_bind] and not by $val.</p>
<p>this is true for foreach loops as well. in fact foreach loops are faster than the while list.</p>
<p>right</p>
<p>foreach($bindvars as $statement_bind =&gt; $variable_bind)<br />
{<br />
    if(! oci_bind_by_name($stmtid, &#8216;:&#8217; . $statement_bind, $bindvars[$statement_bind], -1))<br />
    {<br />
        //Fail<br />
    }<br />
}  </p>
<p>wrong</p>
<p>foreach($bindvars as $statement_bind =&gt; $variable_bind)<br />
{<br />
    if(! oci_bind_by_name($stmtid, &#8216;:&#8217; . $statement_bind, $variable_bind, -1))<br />
    {<br />
        //Fail<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/comment-page-1/#comment-5964</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Tue, 26 Aug 2008 03:40:21 +0000</pubDate>
		<guid isPermaLink="false">http://livebookmark.net/journal/?p=168#comment-5964</guid>
		<description>there is a solution to this which will enable you to use -1, still

if(is_array($bindvars) &amp;&amp; count(array_keys($bindvars)) &gt; 0)
{
   while(list($key, $val) = each($bindvars)) 
   {
      if(! oci_bind_by_name($stmtid, &#039;:&#039; . $key, $bindvars[$key], -1))
      {
         //Error
      }
   }
}</description>
		<content:encoded><![CDATA[<p>there is a solution to this which will enable you to use -1, still</p>
<p>if(is_array($bindvars) &amp;&amp; count(array_keys($bindvars)) &gt; 0)<br />
{<br />
   while(list($key, $val) = each($bindvars))<br />
   {<br />
      if(! oci_bind_by_name($stmtid, &#8216;:&#8217; . $key, $bindvars[$key], -1))<br />
      {<br />
         //Error<br />
      }<br />
   }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harun Yayli</title>
		<link>http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/comment-page-1/#comment-5929</link>
		<dc:creator>Harun Yayli</dc:creator>
		<pubDate>Wed, 07 May 2008 17:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://livebookmark.net/journal/?p=168#comment-5929</guid>
		<description>@cj
thanks for the explanation. It makes sense to me what you&#039;re explaining. The example shown at the php.net&#039;s documentation, has the similar approach that I have. It explicitly sets the size of the field. However the documentation says, on top, the length is optional.
This makes you think that dynamically oci will grab the size of the field by default and throw an error based on the table definition in oracle when oci_execute is called .

PS: I&#039;ve corrected the example.</description>
		<content:encoded><![CDATA[<p>@cj<br />
thanks for the explanation. It makes sense to me what you&#8217;re explaining. The example shown at the php.net&#8217;s documentation, has the similar approach that I have. It explicitly sets the size of the field. However the documentation says, on top, the length is optional.<br />
This makes you think that dynamically oci will grab the size of the field by default and throw an error based on the table definition in oracle when oci_execute is called .</p>
<p>PS: I&#8217;ve corrected the example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cj</title>
		<link>http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/comment-page-1/#comment-5926</link>
		<dc:creator>cj</dc:creator>
		<pubDate>Wed, 07 May 2008 06:16:11 +0000</pubDate>
		<guid isPermaLink="false">http://livebookmark.net/journal/?p=168#comment-5926</guid>
		<description>It makes senses that a length would be required because when the oci_bind_by_name() call is made, there is no data in $$key (a.k.a. $a, $b or $c). Without a length passed, PHP tells the DB to expect a single byte string.

For string binds where the length is not known when binding, use a length that is longer than the longest possible string.  If you don&#039;t know what this is in advance, then re-call oci_bind_by_name() with the actual size prior to each oci_execute() call.

The cardinal rule for binding is that the memory address used in the bind call must continue to exist and be usable when the oci_execute occurs.

The oci_commit() in your example is not needed because oci_execute() commits by default. For best performance and transaction control, use oci_execute($stmt, OCI_DEFAULT).</description>
		<content:encoded><![CDATA[<p>It makes senses that a length would be required because when the oci_bind_by_name() call is made, there is no data in $$key (a.k.a. $a, $b or $c). Without a length passed, PHP tells the DB to expect a single byte string.</p>
<p>For string binds where the length is not known when binding, use a length that is longer than the longest possible string.  If you don&#8217;t know what this is in advance, then re-call oci_bind_by_name() with the actual size prior to each oci_execute() call.</p>
<p>The cardinal rule for binding is that the memory address used in the bind call must continue to exist and be usable when the oci_execute occurs.</p>
<p>The oci_commit() in your example is not needed because oci_execute() commits by default. For best performance and transaction control, use oci_execute($stmt, OCI_DEFAULT).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

