Welcome Guest, Not a member yet? Register   Sign In
Post your controller!
#8

[eluser]Boris Strahija[/eluser]
[quote author="James Brauman" date="1251705590"][quote author="Boris Strahija" date="1251656397"]I think it would be better if you would put your SQL statements into a model. There's a reason why CI is MVC Smile[/quote]
I originally did have them all in model files however I found I was writing methods to select, update, insert and delete things from the database, which to me seems counter-intuitive and a waste of time.

For example I had a method called get() which would take an array of criteria (a key which was the field an value with was the value) and get the content of that record (or records) and return it. But in reality it was just more work than its worth, when I could write the SQL statement in my controller and get just what I need, when I needed it.

I still have some things in my models though, for example I have two tables joined by a pivot table, and one of the methods get the things associated with a record in the other table via pivot table and sorts them.

But its far easier to just leave the select/insert/update/delete functions to the controller.

To me, seperating the view from the logic is absolutely important, but seperating database functions from the controller is only done if there is a reason.[/quote]
I understand that it's easier for you, and I ceartainly won't preach MVC to you Smile It just seems much cleaner code to me when I separate everything in the MVC way, and taht means for me that all data stuff should be in a model. I think it's also important when more than 1 person are working on the project. It can quite easy become a mess if you don't follow the basic rules.


Messages In This Thread
Post your controller! - by El Forum - 08-30-2009, 12:19 AM
Post your controller! - by El Forum - 08-30-2009, 01:36 AM
Post your controller! - by El Forum - 08-30-2009, 07:19 AM
Post your controller! - by El Forum - 08-30-2009, 12:31 PM
Post your controller! - by El Forum - 08-30-2009, 12:44 PM
Post your controller! - by El Forum - 08-30-2009, 08:59 PM
Post your controller! - by El Forum - 08-30-2009, 10:07 PM
Post your controller! - by El Forum - 08-31-2009, 02:13 AM
Post your controller! - by El Forum - 08-31-2009, 03:13 AM
Post your controller! - by El Forum - 08-31-2009, 03:19 AM
Post your controller! - by El Forum - 08-31-2009, 04:43 AM
Post your controller! - by El Forum - 08-31-2009, 04:49 AM
Post your controller! - by El Forum - 09-01-2009, 01:05 AM
Post your controller! - by El Forum - 09-01-2009, 09:30 PM
Post your controller! - by El Forum - 09-02-2009, 02:42 AM
Post your controller! - by El Forum - 09-02-2009, 05:34 AM
Post your controller! - by El Forum - 09-02-2009, 09:02 AM
Post your controller! - by El Forum - 09-02-2009, 09:43 AM
Post your controller! - by El Forum - 09-02-2009, 10:13 AM
Post your controller! - by El Forum - 09-02-2009, 01:13 PM
Post your controller! - by El Forum - 09-03-2009, 06:40 AM
Post your controller! - by El Forum - 11-03-2009, 10:20 PM
Post your controller! - by El Forum - 11-03-2009, 11:02 PM
Post your controller! - by El Forum - 11-03-2009, 11:33 PM
Post your controller! - by El Forum - 11-04-2009, 12:09 AM
Post your controller! - by El Forum - 11-04-2009, 03:36 AM
Post your controller! - by El Forum - 11-04-2009, 07:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB