[eluser]Unknown[/eluser]
Hi,
I wrote a simple controller to fetch a few rows from a database, but I keep getting this weird error notice although everything works as expected. I added a lot of var_dumps to try to determine the cause of the error.
The output of all var_dumps can be seen right after the model!
A PHP Error was encountered
Severity: 4096
Message: Argument 2 passed to Data_model::get_objects() must be an instance of  , string given, called in /var/www/cdn/application/controllers/main.php on line 81 and defined
Filename: models/data_model.php
Line Number: 62
### My controller
// get objects for website_id
$data['rows'] = $this->data_model->get_objects($user_id,$website_id); // row 81, as found in error message
// load view
$this->load->view('website_view.php', $data, $website, $subfunction);
#### My model
function get_objects($user_id, $website_id) // row 62 of data_model.php
{
$this->db->select('uri, ttl, action, cookie_handling');
$this->db->from('objects');
$this->db->where('website_id', $website_id);
$q = $this->db->get();
if($q->num_rows() > 0)
{
foreach($q->result() as $objects)
{
$data[] = $objects;
}
return $data;
}
}
var_dumps for all variables/objects/arrays in controller and data_model:
model $user_id:
string(1) "1"
model $website_id:
string(1) "1"
model $objects:
object(stdClass)#23 (4) { ["uri"]=> string(10) ".(js|css)$" ["ttl"]=> string(4) "3600" ["action"]=> string(6) "lookup" ["cookie_handling"]=> string(1) "1" }
model $data:
array(1) { [0]=> object(stdClass)#23 (4) { ["uri"]=> string(10) ".(js|css)$" ["ttl"]=> string(4) "3600" ["action"]=> string(6) "lookup" ["cookie_handling"]=> string(1) "1" } }
controller $data:
array(4) {
["website"]=>
string(14) "www.bigcdn.com"
["subfunction"]=>
string(7) "objects"
["include_view"]=>
string(20) "website/objects_view"
["rows"]=>
array(1) {
[0]=>
object(stdClass)#23 (4) {
["uri"]=>
string(10) ".(js|css)$"
["ttl"]=>
string(4) "3600"
["action"]=>
string(6) "lookup"
["cookie_handling"]=>
string(1) "1"
}
}
}