Welcome Guest, Not a member yet? Register   Sign In
How do I have a global array in __construct() ?

I have this code.

defined('BASEPATH') OR exit('No direct script access allowed');

class Main extends MY_Controller {

public function __construct()

if (isset($this->me)){ $data['me'] = $this->me; $me = $this->me; }

$notification = $this->db->query("SELECT * FROM posts WHERE noti_recipient = '$me[id]' && noti_read = 'no' && userid != '$me[id]' ORDER BY datetimesecondnumber DESC LIMIT 1 ")->row_array();
if (isset($this->notification)){ $data['notification'] = $this->notification; $me = $this->notification; }


How do I make the $notification variable defined in __construct() a global be passed to all methods in the main controller?

I tried using the public feature but it doesn't work with arrays.

Please help.

Messages In This Thread
How do I have a global array in __construct() ? - by desbest - 08-03-2017, 05:55 AM

Theme © iAndrew 2016 - Forum software by © MyBB