Welcome Guest, Not a member yet? Register   Sign In
problem in form_validation using is_callable(), cannot passing data from controller
#1

(This post was last modified: 04-16-2019, 05:12 AM by DELE.)

I separate all processing data models in libraries, the model is only used to handle data from the database only and the controller is specialized to control requests.

I get a problem when processing data in library_models because of the limitations of calling methods in model_joins, so I tried experimenting so that it became a method below.
controller:
PHP Code:
$this->form_validation->set_rules(
    
'email',
    
'Email',
    [
        
'required',
        [
            
'checkEmail',
            [
                
$this->library_models->check_email($this->model_joins->user_campaign('user_email'$this->input->post('email'))) // problem here
            
]
        ],
        [
            
'checkRole',
            [
                
$this->library_models->check_role($this->model_joins->user_campaign('user_email'$this->input->post('email'))) // problem here
            
]
        ]
    ],
    [
        
'checkEmail'    => 'Email not exists',
        
'checkRole'    => 'Account is not activef'
    
]
); 

libraries:
PHP Code:
public function check_role($email){
    if (
$email->user_role == 0) {
        return 
false;
    }
    return 
true;


models:
PHP Code:
   public function user_campaign($key$value)
 
   {
 
       return $this->db->query("
            SELECT *
            FROM (
                SELECT *
                FROM users
                WHERE 
$key = '$value'
            ) users_campaigns
            INNER JOIN campaigns
            ON users_campaigns.id = campaigns.id
        "
)->row();
 
   

but the results failed, because the above method does not return any values so that it displays the message "Trying to get property 'user_role' of non-object".

please help me to solve this problem.
Reply


Messages In This Thread
problem in form_validation using is_callable(), cannot passing data from controller - by DELE - 04-15-2019, 07:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB