CodeIgniter Forums
New member + Problem with MVC (BambooInvoice) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: New member + Problem with MVC (BambooInvoice) (/showthread.php?tid=22406)



New member + Problem with MVC (BambooInvoice) - El Forum - 09-08-2009

[eluser]The_Stig[/eluser]
How you doing? Im currently in university and have a php course, so i have been playing around with pretty much anything i can to help me get a better understanding. First off what a great product i love how simple it is and i can see why people would use this in the real world. So im now learning about the MVC procedure.

I started playing with the excellent BambooInvoice based on the codeigniter framework and have ran into a problem. I wanted the invoice to have something like Client Name the bit in blue and then under it department name i.e. Client would be Arnold Clark--> Department-> Ford, or something. I have been able to make the new form up so it takes in the new information and stores it in the database.

at
Code:
<h3>&lt;?php echo $row->name;?&gt;</h3>
i added
Code:
&lt;?php echo $row->department;?&gt;
underneath.

This results in the following

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$department

Filename: invoices/view.php

Line Number: 145

any help would be greatly appriciated.


New member + Problem with MVC (BambooInvoice) - El Forum - 09-09-2009

[eluser]überfuzz[/eluser]
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$department

Filename: invoices/view.php

Line Number: 145

Read the error-message!

You're probably loading the view-file in a controller. See to it that you pass $department from it to the viewer.

Code:
$this->data['department'] = "Department of error messages reading";



New member + Problem with MVC (BambooInvoice) - El Forum - 09-09-2009

[eluser]The_Stig[/eluser]
thanks, wasnt that but got me looking in the right place. Managed to fix a few spelling mistakes which didnt help matters


New member + Problem with MVC (BambooInvoice) - El Forum - 09-09-2009

[eluser]überfuzz[/eluser]
[quote author="The_Stig" date="1252501725"]thanks, wasnt that but got me looking in the right place. Managed to fix a few spelling mistakes which didnt help matters[/quote]
Ok! Maybe I should have put it this way. ;-)
Code:
$this->data['department'] = "Department of spelling";
If you're not used to work in different layers it can be tricky to spot whats wrong, even with a crystal clear error-message.


New member + Problem with MVC (BambooInvoice) - El Forum - 09-09-2009

[eluser]The_Stig[/eluser]
Im just coming over to the whole web side of thing and have never done any MVC style of things, finding it interesting however i got confused several times to which file was doing what!

Code:
$this->db->select('invoices.*, clients.name, clients.department, clients.address1.....

Was the final part i had also missed out, imagine forgetting to retrieve from database :o!