Welcome Guest, Not a member yet? Register   Sign In
Nested Query Question (NEWBIE)
#2

[eluser]jedd[/eluser]
Hi JesseR and welcome to the CI forums.

[quote author="JesseR" date="1263440941"]
There are various reasons why I have chosen to do these as completely seperate queries.
I know it can be accomplished in other ways but this is the way we need to do it.
[/quote]

Ask an engineer if the glass is half full, or half empty, and they'll answer 'it's twice as big as it needs to be'. They tend to not like arbitrary conditions wrapped around questions - as it's just a sign of poor design.

Perhaps you could explain why you can't do this properly with a single database call? It would need to be an especially compelling reason to offset the woeful performance-depleting, code-bloating, bug-inducing consequences of looping through queries.

You should also really spend a bit of time - I know it's confusing if you're new to MVC - separating your database queries out into a model. Weirdly enough, this will actually make your intent much easier here. It will also make it much easier to later re-write it as a single, efficient SQL query too. Win-win!

Antepenultimately, rather than doing this (which is pretty confusing code for several reasons)
Code:
$this->db->where('CATEGORY','BECAS'/*$this->uri->segment(3)*/);

...do this instead:
Code:
function  foo ($param1)  {
. . .
$this->db->where('CATEGORY','BECAS'. $param1 );

Penultimately, the foreach: / endforeach constructs you're using in the controller look a bit messy - I think they're indicated (though I never use them) more for where you're wrapping up HTML - jumping in and out of <?php ?> partials and the like.

Finally, and similarly, you want to output your data in a view, not as echos in your controller code. Once you separate your HTML generation and data-acquisition into views and models respectively, I think you'll find your problem becomes much easier to solve.


Messages In This Thread
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 03:49 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:38 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:55 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 05:26 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 11:05 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:35 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 07:12 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 08:42 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 12:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 03:15 AM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB