Welcome Guest, Not a member yet? Register   Sign In
Can I convert empty strings to NULL with a Codeigniter validation rule?
#7

(02-28-2019, 12:25 PM)dave friend Wrote: That sounds like a good approach. I'd like to see the implementation.

I did it and it’s working fine, with strings, and also with numeric values. 
Here is my /application/core/MY_Input.php

PHP Code:
class MY_Input extends CI_Input {
 
   public function post($index NULL$xss_clean NULL)
 
   {
 
       $value$this->_fetch_from_array($_POST$index$xss_clean);
 
       return $value === '' null $value;
 
       //return isset($value) ? $value : (isset($default_fail) ? $default_fail : NULL);
 
   }

Reply


Messages In This Thread
RE: Can I convert empty strings to NULL with a Codeigniter validation rule? - by b126 - 02-28-2019, 12:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB