Welcome Guest, Not a member yet? Register   Sign In
DB error: You must set use the "set" method...
#1

[eluser]butthead[/eluser]
Hello,
I'm almost finishing my first big project in CI. One thing which was revealed during testing is the database error as in the topic:
Quote:You must set use the "set" method to update an entry.
It arrives only when updating or inserting a row into users, using FAL. More precisely, when the "email" field is empty. I've already set correct rules (I mean I hope they are correct...):
Code:
$rules['email'] = 'trim|valid_email|xss_clean|email_backend_duplicate_check';
So, clearly, this field should not be considered as required. I guess it has sth to do with active record class but I'm not so familiar with CI yet to understand where the problem is. Any ideas where to fix the code, appreciated.
#2

[eluser]xwero[/eluser]
[quote author="butthead" date="1203624498"]Hello,
I'm almost finishing my first big project in CI. One thing which was revealed during testing is the database error as in the topic:
Quote:You must set use the "set" method to update an entry.
It arrives only when updating or inserting a row into users, using FAL. More precisely, when the "email" field is empty. I've already set correct rules (I mean I hope they are correct...):
Code:
$rules['email'] = 'trim|valid_email|xss_clean|email_backend_duplicate_check';
So, clearly, this field should not be considered as required. I guess it has sth to do with active record class but I'm not so familiar with CI yet to understand where the problem is. Any ideas where to fix the code, appreciated.[/quote]

Can you show your email_backend_duplicate_check code? Putting it like that in the rules will cause an error too. You have to prefix your custom functions with callback.
#3

[eluser]butthead[/eluser]
Thanks for quick reply. I'm using the original code taken from FreakAuth Light FAL_validation.php:
Code:
function email_backend_duplicate_check($value)
{    
    //Use the input e-mail and check against 'users' table
    //checks if the request comes from add or edit actions
    //query in main user table (users already activated)
    $fields='id';
    $where = isset($_POST['id']) ?  array('id !='=> $_POST['id'], 'email'=>$value) : array('email'=>$value);
    $query = $this->CI->UserModel->getUsers($fields, $limit=null, $where);
    if (($query != null) && ($query->num_rows() > 0))
    {
        $this->set_message('email_backend_duplicate_check', $this->CI->lang->line('FAL_user_email_duplicate'));
        $query->free_result();
        return false;
    }
    //query in temporary user table (users waiting for activation)
    //only if registration with email verification
    if (!$this->CI->config->item('FAL_register_direct'))
    {
        $fields='id';
        $where=array('email'=>$value);
        $query_temp = $this->CI->UserTemp->getUserTempWhere($fields, $where);
            
        if (($query_temp != null) && ($query_temp->num_rows() > 0))
        {
            $this->set_message('email_backend_duplicate_check', $this->CI->lang->line('FAL_usertemp_email_duplicate'));
                
            $query_temp->free_result();
            return false;
        }
    }
        
    return true;
}
Even if I add "callback_" prefix in the controller, it doesn't fix the problem.
#4

[eluser]xwero[/eluser]
I see nothing i this function that builds a sql statement. The problem is located in the UserModel->getUsers i think.

To get an answer the quickest i suggest you should ask the question in the FreakAuth Light thread. Those guys are very helpful.
#5

[eluser]Grahack[/eluser]
I answered in this post.
There a line like
Code:
if (($values['user']['user_name'] != false) && ($values['user']['email'] != false))
in application/controllers/admin/users.php. I just discover it with you. This part is a bit tricky. Please keep us informed in FAL's thread.




Theme © iAndrew 2016 - Forum software by © MyBB