This particular application has been in use for over a year now, and uses several dozen models, and I am having trouble only with this one particular new function.
public function get_slides($promo = NULL) {
$sql = "SELECT description as alt, image, link
FROM " . CONFIG_DATABASE . ".slides
WHERE active = '1' AND acct_no = '" . API_ACCT . "' ORDER BY priority ASC;";
$query = $this->db->query($sql);
var_dump($sql);
var_dump($query);
return $query->result_array();
}
The results of this are:
string 'SELECT description as alt, image, link
FROM web_config_development.slides
WHERE active = '1' AND acct_no = '10001' ORDER BY priority ASC;' (length=143)
boolean false
Followed by:
Fatal error: Call to a member function result_array() on a non-object
The query works fine in MySQL Workbench. In my searching for this issue I have come across docs referring to true/false responses on INSERT and DELETE, but not on SELECT.
This does not make any sense ... if you have any ideas, sharing them would be greatly appreciated.
The issue was table permissions. The application user was not added to the new table.
I believe you are calling the wrong method to get the result.
Try this
return $query->result();
For more information about about Codeigniter active record go here
if used result_array() then first will be checked number of rows in query
if($query->num_rows()>0){
return $query->result_array();
}else {
return 0;
}