0

I have been having an issue with a database query returning a boolean instead of result_array() or result_object. This seems very convoluted.

Below is the normal core query that is supposed to return a result:

$query = $this->db->query('MY_QUERY');
return $query->result_array();

To be more precise, the core code is generating a fatal_error when I use form validation from the core library to validate the is_unique $this->input

Fatal error: Call to a member function num_rows() on boolean in 
C:\xampp\htdocs\MY_PROJECT\system\libraries\Form_validation.php on line 1122
1
  • Returning FALSE instead of an empty result set indicates an error with your query. You have not provided this, so it is difficult to diagnose. Commented Feb 26, 2018 at 1:56

1 Answer 1

1

Boolean usually means the query returned false. As you are specifying form validation is unique function - check that the table is spelled correctly and exists and that the corresponding field/column is spelled correctly and exists.

The proper syntax for the is unique function as a pipe separated rule is is_unique[table.fieldname]

The form validation is unique function doesn't check if the result object returns true or false it just immediately runs num rows on the result which will result in this error message if the query failed.

If after having checked that your inputs are correct (table and column names) and you are still receiving an error - turn on db debug in the config. This should provide more context to you as to why it is failing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.