I have read 1, 2 and several other threads prior to post this issue but none of them solved my problem. I am totally new with PHP and got stuck in attempting to learn MVC with codeigniter. The function which causing error is
public function get_results()
{
$libraries = array("", "JQuery", "MooTools", "YUI Library", "Glow");
$table_rows = '';
for ($i = 1; $i < 5; $i++)
{
$this->db->select('COUNT(choice) choices_count')->from('js_libraries')->where('choice',$i);
$result = $this->db->get();
$table_rows .= "<tr><td>" . $libraries[$i] . " Got:</td><td><b>" . $result[0] . "</b> votes</td></tr>";
}
}
I have executed the query on phpmyadmin and it shows result (a single integer) but I am unable to make this CI_DB_mysql_result object work. I have tried all result(), result_array(), getResult() functions but it says undefined functions for this kind of object. How can I get result from CI_DB_mysql_result?
result_arraymethod to get result as array.$result = $this->db->get()->result_array();Array to string conversionerror on next line when getting results from $result[0]