Welcome Guest, Not a member yet? Register   Sign In
MY_ Subclass not loading - URGENT
#1

[eluser]CI-Newb[/eluser]
Hello, I've added the following to "My_Form_validation.php" to allow 'updates' with unique values:

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class My_Form_validation extends CI_Form_validation {

  public function is_unique($str, $field)
  {
    list($table, $field)=explode('.', $field);
    $q = $this->CI->db->query("SHOW KEYS FROM $table WHERE Key_name = 'PRIMARY'")->row();
    $primary_key = $q->Column_name;

    if($this->CI->input->post($primary_key) > 0):
      $query = $this->CI->db->limit(1)->get_where($table, array($field => $str,$primary_key.' !='=>$this->CI->input->post($primary_key)));
    else:
      $query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
    endif;
    return $query->num_rows() === 0;
  }
}


/* End of file My_Form_validation.php */
/* Location: ./application/libraries/My_Form_validation.php */

This works perfectly on my localhost environment. When I upload it to the live server it does not function. When I enable the profiler I can see that it actually isn't working, (see below)

Code:
Localhost:
0.0005   SHOW KEYS FROM users WHERE Key_name = 'PRIMARY'
0.0003   SELECT *
FROM (`users`)
WHERE `username` =  'mike'
AND `id` != '1'
LIMIT 1  


LiveServer:(same code)
0.0001   SELECT *
FROM (`users`)
WHERE `username` =  'mike'
LIMIT 1


Would anyone happen to have any idea's why this could be happening and how to fix it? Why will this not load?
#2

[eluser]CI-Newb[/eluser]
**UPDATE**

I've added a simple "echo 'hello';" to the MY_file. On the local host it echo's 'hello' correctly everytime the form tries to validate something with is_unique form works perfectly no other problems... on the live server it echo's nothing which leads me to believe the file isn't being loaded / used at all... What would cause this file not to be called on the production server but be called on my localhost?
#3

[eluser]Aken[/eluser]
File/folder capitalization, most likely. The correct file and class name is MY_Form_validation.php. If that doesn't work, try making the file name entirely lower case. Some servers are more strict with case, others aren't.
#4

[eluser]CI-Newb[/eluser]
Thank you!! Mystery Solved!




Theme © iAndrew 2016 - Forum software by © MyBB