php - Codeigniter -fetching data sitewide with codeigniter hooks -


i trying scroll news in page of website database without having pass variable in every controller of site. decided use hooks instead of passing scroll variable in every controller.

i did create class this

class scroll {   function getscroller()  {    $data = array();    $ci =& get_instance();    $ci->db->where('a_status','active');   $ci->db->limit(4);   $ci->db->order_by('id','desc');    $q = $ci->db->get('news');   if($q->num_rows() > 0){     foreach($q->result_array() $row){         $data[] = $row;     }   }   $q->free_result();   return $data;  }    } 

what

severity: notice  message: trying property of non-object call member function get() on non-object in e:\xampp\htdocs\ 

can please me how ? want scrollernews in controller's view automatically without having pass in each controller. thanks

if defining on view level, there no need that.

you can define db requests directly in view.

other approach have separated controller separate view , load in page through iframe. it's used "web widgets" can later on loaded in pages.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -