Welcome Guest, Not a member yet? Register   Sign In
Problems with custom library
#1

[eluser]Dave Blencowe[/eluser]
Firstly, I am using a library created by my friend, it can be found here

When I load a file with his library using $this->template->load(); everything loads correctly and works fine until I try to use another codeigniter function within the loaded file, such as $this->db->get();
The database class is loaded and works anywhere else but here I get the following error:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Template::$db

Filename: MySite/footer.php

Line Number: 2

Does anyone have any ideas on what is happening and why?

Thanks,
Dave,
#2

[eluser]pistolPete[/eluser]
Just don't try to access the database in the view, that's what Models are used for in the MVC approach:
user_guide/overview/mvc.html
#3

[eluser]Dave Blencowe[/eluser]
Yeah I know, I thought I had a valid reason for doing it, but looking back I don't think it is anymore. Still, anyone know how to solve it for future reference?

If it is a feature implemented in the view loader then I would like to get it right in the template library too.

EDIT: There is a valid reason for this sorry, it is a Header/Footer so I don't want to have to repeat the database code every time I load the Header/Footer




Theme © iAndrew 2016 - Forum software by © MyBB