Welcome Guest, Not a member yet? Register   Sign In
Run query in view rather than controller
#1

[eluser]Unknown[/eluser]
Hi,

I need to execute a query in view rather than in controller. Can any body help me please how to call. If I call it gives the error message

Severity: Notice

Message: Undefined property: CI_Loader::$db

Filename: views/floorplan.php

Line Number: 57
#2

[eluser]prestondocks[/eluser]
Could you provide the reason for running the query in the View. You are working outside of the Model, View, Controller framework if you put data access or too much logic in your views.

We may be able to help you put the query back in the model where it should be if we understand the what you are trying to do.

Simon
#3

[eluser]danmontgomery[/eluser]
Code:
$CI =& get_instance();
$CI->db->...
#4

[eluser]smilie[/eluser]
+1 for prestondocks - do not mix queries in your view :-) Follow MVC moddel Smile

Cheers,
Smilie
#5

[eluser]Juan Velandia[/eluser]
+2 for prestondocks, there's no reason to put querys into the view... think ahead!

Please check this thread, It uses mvc structure. The tables names are different but it’s easy (I think) to figure it out

http://ellislab.com/forums/viewthread/149458/

hope it helps
#6

[eluser]Sean Gates[/eluser]
+3 for prestondocks, +1 for Juan Velandia.




Theme © iAndrew 2016 - Forum software by © MyBB