problem in form_validation using is_callable(), cannot passing data from controller |
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( libraries: PHP Code: public function check_role($email){ models: PHP Code: public function user_campaign($key, $value) 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.
You're going to have to show us the code for model_joins::user_campaign before we can offer much advice. Clearly though the problem is that model_joins::user_campaign does not return an object with a user_role method.
(04-15-2019, 07:15 PM)dave friend Wrote: You're going to have to show us the code for model_joins::user_campaign before we can offer much advice. Clearly though the problem is that model_joins::user_campaign does not return an object with a user_role method. I think there is no problem with model_joins :: user_campaign. but I have updated my post.
(04-15-2019, 07:40 PM)DELE Wrote: I think there is no problem with model_joins :: user_campaign. but I have updated my post. There is a problem because user_campaign is not returning an object. This will be the case when CI_DB_result::row() returns null. It returns null when there are no records returned by the query. (04-15-2019, 08:10 PM)dave friend Wrote:(04-15-2019, 07:40 PM)DELE Wrote: I think there is no problem with model_joins :: user_campaign. but I have updated my post. why does it not return object values? instead returns a null value? and how do I overcome that using the is_callable() method? I tried the callback method before using a query from user_campaign and it worked well without any problems.
(04-15-2019, 09:49 PM)DELE Wrote: why does it not return object values? instead returns a null value? and how do I overcome that using the is_callable() method? It returns no object because no record in the database satisfied the where condition. In other words, there is no data to turn into an object. Perhaps the easiest solution is to have the callback respond in a logical way when its argument is null. Oh... and for what it's worth. The following PHP Code: public function check_role($email){ would be much more concise if written like this PHP Code: public function check_role($email){ Or, if you want to account for the argument possibly being null PHP Code: public function check_role($email){
It seems like you failed to understand my point. actually there are no problems in my libraries and models. I have tested everything.
I asked how to pass data from the controller using form_validation with is_callable(). the problem is here. https://www.codeigniter.com/user_guide/l...-as-a-rule he only passed data from $_post |
Welcome Guest, Not a member yet? Register Sign In |