Codeigniter - Call to a Member Function Result() on Boolean In

Codeigniter Fatal Error Call to a member function result() on boolean

I ran the query without putting return and got a syntax error. The problem was anything regarding USER had to become [USER]

How to fix this 'Call to a member function row() on boolean' error?

I think the problem is with the query:

SELECT * from sma_sales  desc limit 1 where customer_id = '$id'

Try something like this:

SELECT * from sma_sales where customer_id = '$id' order by `sales_date` desc limit 1

You need to use the ORDER BY clause to do the sorting.

Also, make sure you escape the $id before including it inside the query. Have a look at this.

Another suggestion is that, you could check whether the $result is set or not. Because in case of errors, it would return NULL. Read more about it here.

getting error Call to a member function result() on boolean when i try to use group_by function in codeigniter

My guess is the sales_id column name on this line is ambiguous :

->group_by('sales_id');

So you could change it either using sales.sales_id or invoice.sales_id :

->group_by('s.sales_id');

Codeigniter - Call to a member function result_array() on boolean - Local setup Installation error

Try to replace:

return $result = $this->db->get()->result_array();

with

return $this->db->get() ? $this->db->get()->result_array() : [];

It names ternary operator, works similar to if statement:

if ($this->db->get()) {} else {}

This error occurs cause of $this->db->get() returns a boolean value (true/false)

Call to a member function result() on boolean error after switching to sqlsrv dbdriver

First things first, NEVER put variables directly into a query. Always use parameter binding like this:

function get_myeligible_info($id)
{
$sql = "SELECT * FROM emp_list_manila WHERE employee_empid = ?";
$query = $this->db->query($sql, [$id]);
return $query->result();
}

For stored procedures, you can't just call them by name, you have to use EXEC:

function get_for_batch_insert2()
{
$query = $this->db->query("EXEC INSERT_TTUMBATCH");
return $query->result();
}

For both these calls, you should be checking for errors and dealing with them appropriately:

function get_for_batch_insert2()
{
$query = $this->db->query("EXEC INSERT_TTUMBATCH");
if ($query) {
return $query->result();
} else {
return false;
}
}


Related Topics



Leave a reply



Submit