Welcome Guest, Not a member yet? Register   Sign In
Noob: Some basics things I'm apparently not getting
#1

[eluser]CheekyGeek[/eluser]
QUESTION 1
Is there a good tutorial somewhere specifically on passing variables the OO/MVC way? (CodeIgniter-specific tutorial would be best, but I have the feeling that any OO PHP tutorial will teach the same concepts. Correct me if I'm wrong.) It seems like a lot of questions on this forum (including mine) have to do with misunderstandings of this basic concept.

I worked along with the video tutorials but they did not involve models and it seems that I'm not getting something right between calling my model functions and passing the results on to the view. If models are a good idea, then it would seem that there should be some more advanced tutorials showing them being used.

QUESTION 2
Also, can you MIX your style of working with the database? Looking at the User Guide (Database Quick Start) I see multiple ways of doing things (Standard Query, object version; Standard Query, array version, and Active Record query). If you use Active Record (which is what I'd really like to learn exclusively) do you need to do Active Record everywhere or can you use the other methods in other places?

I'm using a model that I copied from a tutorial site and modified to work with my db table and I'm not sure if that is helping me or hindering me.
#2

[eluser]SeanJA[/eluser]
I suggest this here:

Rolling your own MVC

I found it quite informative (though, I am not planning on writting my own MVC right now). It doesn't have the full tutorial just yet, but it should give you a start on what you need to know.
#3

[eluser]parrots[/eluser]
Addressing your question about the DB it is ok to mix active record and regular queries. Personally I stick with one way of dealing the results (array vs object, I favor object-based result access) but mixing would work there too. Sticking with one way for each just makes your code easier to read and more maintainable in the long-run.
#4

[eluser]xwero[/eluser]
Passing the data has more to do with your way of codeing than with OO. I changed my front controller to pass the data to the load->vars method so i don't have to do it in the controller (Custom front controller). Without my changes you could add the load->vars method to the model method for the page so the only thing you have to do in the controller is calling the method.

For your second question you are not, at any time, restricted to a sort of methods. They all serve their purpose but i think the easiest way is using the AR methods. Actually the AR methods have nothing to do with the query result itself. That is handled by the database/DB_result.php file.
Use AR for the most queries, when you have a complex sql statement you can use the query method.
Use the result object for outputting most of your data and use the result array when you can't or don't want to manipulate the data in the sql statement.




Theme © iAndrew 2016 - Forum software by © MyBB