Error in getting for SQL results in codeIgniter. When I use same query in phpmyadmin I got my results successfully.
What’s wrong, please help.
MODEL:
public function calculateScore()
{
$team_points = $this->db->query('SELECT teams.team_name,
COUNT(matches.winner) AS Win
FROM
matches
RIGHT JOIN teams ON teams.team_name = matches.winner
GROUP BY teams.team_name, matches.winner
ORDER BY win DESC');
return $team_points;
}
ERROR:
{
"conn_id": {
"affected_rows": null,
"client_info": null,
"client_version": null,
"connect_errno": null,
"connect_error": null,
"errno": null,
"error": null,
"error_list": null,
"field_count": null,
"host_info": null,
"info": null,
"insert_id": null,
"server_info": null,
"server_version": null,
"sqlstate": null,
"protocol_version": null,
"thread_id": null,
"warning_count": null
},
"result_id": {
"current_field": null,
"field_count": null,
"lengths": null,
"num_rows": null,
"type": null
},
"result_array": [],
"result_object": [],
"custom_result_object": [],
"current_row": 0,
"num_rows": null,
"row_data": null
}
2
Answers
Use this
Instead of
If you need an array as result:
Or just std object:
In addition, I think there is an error in your sql statement.
Did you intend to write: