Welcome Guest, Not a member yet? Register   Sign In
How to convert from Mysql query to Codeigniter syntax?
#4

[eluser]slowgary[/eluser]
You still need to call ->result() or ->result_array() on the query. Also, you'd need to determine which field you want to echo, as echoing $count will try to echo an object, which is what's causing the error. So:
Code:
$count = $this->db->select(‘COUNT(lib_books.boo_id)AS number’, FALSE)->join(‘lib_books’, ‘lib_books.boo_id = lib_borrowings.boo_id’, ‘inner’)->group_by(‘lib_books.boo_id’)->get(‘lib_borrowings’)->result_array();
      echo $count['number'];

I think that should work. Also, please use the [ code ] tags when posting code.


Messages In This Thread
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-16-2009, 09:15 PM
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-16-2009, 09:22 PM
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-16-2009, 09:42 PM
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-16-2009, 10:09 PM
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-16-2009, 11:09 PM
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-17-2009, 02:42 AM
How to convert from Mysql query to Codeigniter syntax? - by El Forum - 06-17-2009, 02:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB