<?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: Extending CodeIgniter&#8217;s Validation Library To Check For Unique Values</title>
	<atom:link href="http://www.ScottNelle.com/41/extending-codeigniters-validation-library/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/</link>
	<description>Scott Nellé&#039;s Personal Site</description>
	<lastBuildDate>Thu, 12 Jan 2012 12:02:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Gabe</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-39269</link>
		<dc:creator>Gabe</dc:creator>
		<pubDate>Mon, 05 Dec 2011 22:54:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-39269</guid>
		<description>EXCELLENT!!! Worked perfectly! Thanks for your contribution and please keep it up!</description>
		<content:encoded><![CDATA[<p>EXCELLENT!!! Worked perfectly! Thanks for your contribution and please keep it up!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mic B</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-37581</link>
		<dc:creator>Mic B</dc:creator>
		<pubDate>Mon, 14 Nov 2011 13:06:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-37581</guid>
		<description>Hi,

Very useful thanks,

However you stated that including the validation callbacks in your controllers/models looked messy. I agree with this but I don&#039;t extend the form_validation library, I just create a form_validation helper that contains all the additional callback functions. 

I know both ways are valid, but its always nice to have more than one way to achieve a task :D</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Very useful thanks,</p>
<p>However you stated that including the validation callbacks in your controllers/models looked messy. I agree with this but I don&#8217;t extend the form_validation library, I just create a form_validation helper that contains all the additional callback functions. </p>
<p>I know both ways are valid, but its always nice to have more than one way to achieve a task :D</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aurimas</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-33937</link>
		<dc:creator>Aurimas</dc:creator>
		<pubDate>Thu, 29 Sep 2011 19:59:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-33937</guid>
		<description>Hi everyone, 

Script is way better that I used before, but now I faced a problem, that my register form does not show a message which I set. I t works, but message does not appear. My script:

&lt;?php if (!defined(&#039;BASEPATH&#039;)) exit(&#039;No direct script access allowed&#039;);
/**
 * MY_Form_validation Class
 *
 * Extends Form_Validation library
 *
 * Adds one validation rule, &quot;email_check&quot; and accepts a
 * parameter, the name of the table and column that
 * you are checking, specified in the forum table.column
 *
 * Note that this update should be used with the
 * form_validation library introduced in CI 1.7.0 
 */
class MY_Form_validation extends CI_Form_validation {

	function __construct()
	{
	    parent::__construct();
	}

	// --------------------------------------------------------------------

	/**
	 * Email_check
	 *
	 * @access	public
	 * @param	string
	 * @param	field
	 * @return	bool
	 */

	function email_check($str, $field)
	{
		$CI =&amp; get_instance();
		list($table, $column) = explode(&#039;.&#039;, $field, 2);

		$CI-&gt;form_validation-&gt;set_message(&#039;email_check&#039;, &#039;The %s that you requested is already in use.&#039;);

		$query = $CI-&gt;db-&gt;query(&quot;SELECT COUNT(*) AS dupe FROM $table WHERE $column = &#039;$str&#039;&quot;);
		$row = $query-&gt;row();
		return ($row-&gt;dupe &gt; 0) ? FALSE : TRUE;
	}
}
?&gt;

And I used:
 $this-&gt;my_form_validation-&gt;set_rules(&#039;email_address&#039;, &#039;Email Address&#039;, &#039;email_check[reg_users.email]&#039;);

I did it this way, because your exact code did not worked. I use 2.x version</description>
		<content:encoded><![CDATA[<p>Hi everyone, </p>
<p>Script is way better that I used before, but now I faced a problem, that my register form does not show a message which I set. I t works, but message does not appear. My script:</p>
<p>&lt;?php if (!defined(&#039;BASEPATH&#039;)) exit(&#039;No direct script access allowed&#039;);<br />
/**<br />
 * MY_Form_validation Class<br />
 *<br />
 * Extends Form_Validation library<br />
 *<br />
 * Adds one validation rule, &quot;email_check&quot; and accepts a<br />
 * parameter, the name of the table and column that<br />
 * you are checking, specified in the forum table.column<br />
 *<br />
 * Note that this update should be used with the<br />
 * form_validation library introduced in CI 1.7.0<br />
 */<br />
class MY_Form_validation extends CI_Form_validation {</p>
<p>	function __construct()<br />
	{<br />
	    parent::__construct();<br />
	}</p>
<p>	// &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>	/**<br />
	 * Email_check<br />
	 *<br />
	 * @access	public<br />
	 * @param	string<br />
	 * @param	field<br />
	 * @return	bool<br />
	 */</p>
<p>	function email_check($str, $field)<br />
	{<br />
		$CI =&amp; get_instance();<br />
		list($table, $column) = explode(&#8216;.&#8217;, $field, 2);</p>
<p>		$CI-&gt;form_validation-&gt;set_message(&#8216;email_check&#8217;, &#8216;The %s that you requested is already in use.&#8217;);</p>
<p>		$query = $CI-&gt;db-&gt;query(&#8220;SELECT COUNT(*) AS dupe FROM $table WHERE $column = &#8216;$str&#8217;&#8221;);<br />
		$row = $query-&gt;row();<br />
		return ($row-&gt;dupe &gt; 0) ? FALSE : TRUE;<br />
	}<br />
}<br />
?&gt;</p>
<p>And I used:<br />
 $this-&gt;my_form_validation-&gt;set_rules(&#8216;email_address&#8217;, &#8216;Email Address&#8217;, &#8216;email_check[reg_users.email]&#8216;);</p>
<p>I did it this way, because your exact code did not worked. I use 2.x version</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benji</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-30906</link>
		<dc:creator>Benji</dc:creator>
		<pubDate>Wed, 31 Aug 2011 13:41:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-30906</guid>
		<description>one observation : you can also have protection for duplicates right from the database by setting the field unique, even in the case of a pair (firstname,lastname) setting the index on multiple columns like this : 

ALTER TABLE users ADD UNIQUE INDEX(firstname, lastname);</description>
		<content:encoded><![CDATA[<p>one observation : you can also have protection for duplicates right from the database by setting the field unique, even in the case of a pair (firstname,lastname) setting the index on multiple columns like this : </p>
<p>ALTER TABLE users ADD UNIQUE INDEX(firstname, lastname);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jiqqa</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-28908</link>
		<dc:creator>jiqqa</dc:creator>
		<pubDate>Thu, 11 Aug 2011 08:26:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-28908</guid>
		<description>nevermind he states to place it in:
&quot;system/application/libraries/&quot;

works after its placed in:
&quot;application\libraries&quot;</description>
		<content:encoded><![CDATA[<p>nevermind he states to place it in:<br />
&#8220;system/application/libraries/&#8221;</p>
<p>works after its placed in:<br />
&#8220;application\libraries&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jiqqa</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-28907</link>
		<dc:creator>jiqqa</dc:creator>
		<pubDate>Thu, 11 Aug 2011 08:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-28907</guid>
		<description>Hi all im running the latest version of CI

i added the My_Form_validation to libraries that looks like this http://pastebin.com/YWnMu6fe

my form validation looks like this:
$this-&gt;form_validation-&gt;set_rules(&#039;username&#039;, &#039;Username&#039;, &#039;required&#124;min_length[4]&#124;unique[members.username]&#039;);

but the username still gets inserted with a dupe. Can someone help?</description>
		<content:encoded><![CDATA[<p>Hi all im running the latest version of CI</p>
<p>i added the My_Form_validation to libraries that looks like this <a href="http://pastebin.com/YWnMu6fe" rel="nofollow">http://pastebin.com/YWnMu6fe</a></p>
<p>my form validation looks like this:<br />
$this-&gt;form_validation-&gt;set_rules(&#8216;username&#8217;, &#8216;Username&#8217;, &#8216;required|min_length[4]|unique[members.username]&#8216;);</p>
<p>but the username still gets inserted with a dupe. Can someone help?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos Vergara</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-27221</link>
		<dc:creator>Carlos Vergara</dc:creator>
		<pubDate>Mon, 25 Jul 2011 22:10:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-27221</guid>
		<description>I also noticed the problem when updating a record. Anyone has a solution for that case?

By the way well done, I hope anyone can guide me to solve it.</description>
		<content:encoded><![CDATA[<p>I also noticed the problem when updating a record. Anyone has a solution for that case?</p>
<p>By the way well done, I hope anyone can guide me to solve it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Koudjo</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-21316</link>
		<dc:creator>Koudjo</dc:creator>
		<pubDate>Mon, 06 Jun 2011 17:18:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-21316</guid>
		<description>Thanks for this librairy. 
Make sure to use the right Class Extension Prefix
(set in your config file).
Kind Regards 
Koudjo</description>
		<content:encoded><![CDATA[<p>Thanks for this librairy.<br />
Make sure to use the right Class Extension Prefix<br />
(set in your config file).<br />
Kind Regards<br />
Koudjo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giordon Stark</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-20710</link>
		<dc:creator>Giordon Stark</dc:creator>
		<pubDate>Mon, 30 May 2011 14:12:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-20710</guid>
		<description>There&#039;s an issue with compatibility using form_validation.php external rules - I had to make the following change (http://stikked.com/view/7fc106ca).

    //OLD
    class MY_Form_validation extends CI_Form_validation {
     
            function __construct()
            {
                    parent::__construct();
            }
    }
     
    //NEW
    class MY_Form_validation extends CI_Form_validation {
     
            function __construct($rules = array())
            {
                    parent::__construct();
                    $this-&gt;_config_rules = $rules;
            }
    }</description>
		<content:encoded><![CDATA[<p>There&#8217;s an issue with compatibility using form_validation.php external rules &#8211; I had to make the following change (<a href="http://stikked.com/view/7fc106ca" rel="nofollow">http://stikked.com/view/7fc106ca</a>).</p>
<p>    //OLD<br />
    class MY_Form_validation extends CI_Form_validation {</p>
<p>            function __construct()<br />
            {<br />
                    parent::__construct();<br />
            }<br />
    }</p>
<p>    //NEW<br />
    class MY_Form_validation extends CI_Form_validation {</p>
<p>            function __construct($rules = array())<br />
            {<br />
                    parent::__construct();<br />
                    $this-&gt;_config_rules = $rules;<br />
            }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joni Q.</title>
		<link>http://www.ScottNelle.com/41/extending-codeigniters-validation-library/comment-page-1/#comment-20461</link>
		<dc:creator>Joni Q.</dc:creator>
		<pubDate>Fri, 27 May 2011 17:51:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.scottnelle.com/?p=41#comment-20461</guid>
		<description>Hi Scott,

Very useful and clean function!
Thank you for sharing this!</description>
		<content:encoded><![CDATA[<p>Hi Scott,</p>
<p>Very useful and clean function!<br />
Thank you for sharing this!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

