Note that there are some explanatory texts on larger screens.

plurals
  1. POCode Igniter not letting me load multiple libraries
    primarykey
    data
    text
    <p>I am building an application using the Code Igniter framework in which I have built many different libraries of which I load into the controllers they are needed in.</p> <p>When I try and load multiple libraries into my 'home' controller I get the following message:</p> <pre><code>A PHP Error was encountered Severity: Notice Message: Undefined property: Home::$messaging Filename: controllers/home.php Line Number: 73 Fatal error: Call to a member function getMessages() on a non-object in /home/totalcar/public_html/application/controllers/home.php on line 73 </code></pre> <p>I have never encountered this error before as I have had controllers before loading multiple libraries no problem. It seems to think that the messaging library doesn't exist or is not being loaded. I have ensured that the filenames for the libraries have a capital first letter, as do the class declarations and this doesn't seem to make any difference.</p> <p>I load my libraries seperately as shown below. (Please note I have removed lots of irrelevant code from the controller to make it easier to read here)</p> <pre><code>public function index() { ... //Load Helpers $this-&gt;load-&gt;helper('menu'); $this-&gt;load-&gt;helper('layout'); //Load Libraries $this-&gt;load-&gt;library('pusher'); $this-&gt;load-&gt;library('test'); //Load User Details $data['userid'] = $this-&gt;session-&gt;userdata('userid'); $data['modules'] = getModules($this-&gt;layout_model, $this-&gt;socialmedia_model); //Build Menu $data['menuItems'] = buildMenu($this-&gt;session-&gt;userdata('user_group_id'), $this-&gt;config); $data['firstName'] = $this-&gt;session-&gt;userdata('firstName'); //Unread Messages $options = array( 'userId' =&gt; $data['userid'], 'opened' =&gt; 0 ); $this-&gt;load-&gt;library('messaging', $options); $data['unreadMessages'] = $this-&gt;messaging-&gt;getMessages(); $data['mailIcon'] = (empty($data['unreadMessages'])) ? "mailButton.png" : "mailButtonUnread.png"; </code></pre> <p>Can anybody offer any guidance here? Thanks</p> <p>Edit: here is my library code:</p> <pre><code>&lt;?php if(!defined('BASEPATH')) exit('No direct script access allowed'); class Messaging extends CI_Controller { private $options; private $unreadMessages; public $mailIcon; function __construct($options) { parent::__construct(); $this-&gt;load-&gt;model('messaging_model'); $this-&gt;load-&gt;model('staff_model'); $this-&gt;options = $options; } function getMessages() { $unreadMessages = $this-&gt;messaging_model-&gt;getMessages($this-&gt;options); $this-&gt;unreadMessagesReturn = array(); $mailIcon = (empty($unreadMessages)) ? "mailButton.png" : "mailButtonUnread.png"; if(!empty($unreadMessages)) { foreach($unreadMessages as $message) { $fromUserDetails = $this-&gt;staff_model-&gt;getStaffMemberDetails($message['from_id']); if((isset($fromUserDetails['profile_image_small'])) &amp;&amp; $fromUserDetails['profile_image_small'] != "") { $profileImageSmall = $this-&gt;config-&gt;base_url() . "images/profileImages/" . $fromUserDetails['profile_image_small']; } else { $profileImageSmall = $this-&gt;config-&gt;base_url() . "images/noImage.png"; } $name = $fromUserDetails[0]['first_name'] . " " . $fromUserDetails[0]['last_name']; $dateSent = date('Y-m-d', strtotime($message['time_sent'])); $messageTruncated = substr($message['message'], 0, 70) . "..."; $this-&gt;unreadMessagesReturn[] = array( 'fromPic' =&gt; $profileImageSmall, 'fromName' =&gt; $name, 'subject' =&gt; $message['subject'], 'message' =&gt; $message['message'], 'messageTruncated' =&gt; $messageTruncated, 'dateSent' =&gt; $dateSent ); } return $this-&gt;unreadMessagesReturn; } } } </code></pre> <p>?></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload