Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter - Doctrine ORM Tutorial : A way of enhancing CI
#11

[eluser]Burak Guzel[/eluser]
[quote author="wiredesignz" date="1258439879"]You've done a huge amount of work here and I'm sure it's greatly appreciated by the community.

I'm beginning to believe that it's not such a good idea to use any data objects in the controller directly.

Doing this then requires all of your application business logic to be in the controller also when it should really be in your models.

The model should encapsulate the Doctrine objects rather than being replaced by them. Even your diagram (in Part 1) shows business logic being in models but your code examples don't.[/quote]

Can you be more specific? I am open to suggestions.
#12

[eluser]wiredesignz[/eluser]
I thought that was specific.

Business logic is that logic that makes your application function and is not related to the request, input validation or the response.

The business logic is that which might ensure a user does not register with a username of `Administrator` or that some monetary value when multiplied by some other value does not end up being a negative number etc.

Your models in an MVC context, are supposed to provide this logic. Your data objects should be encapsulated by the model and used in context of the application business logic.
#13

[eluser]kikz4life[/eluser]
hi there,

just want to ask if ORM support xampp? haven't tried yet ORM. Big Grin

thanks
#14

[eluser]Burak Guzel[/eluser]
[quote author="wiredesignz" date="1258441534"]I thought that was specific.

Business logic is that logic that makes your application function and is not related to the request, input validation or the response.

The business logic is that which might ensure a user does not register with a username of `Administrator` or that some monetary value when multiplied by some other value does not end up being a negative number etc.

Your models in an MVC context, are supposed to provide this logic.[/quote]

Doctrine does have support for Data Validation, and it's actually more extensive than the CI form_validation class. And it also supports custom validators, where you could for example check for special usernames like ('Administrator') as you just mentioned.

I am already planning on making that part of an upcoming episode.

The thing is, I just can't present all the concepts at once in the very first Model I create in the tutorials. I need to go at a certain pace, as these are meant to be readable by beginners in CI and Doctrine.

Thanks for bringing it up though. If you have any other specific suggestions let me know.
#15

[eluser]Burak Guzel[/eluser]
[quote author="kikz4life" date="1258442306"]hi there,

just want to ask if ORM support xampp? haven't tried yet ORM. Big Grin

thanks[/quote]

It should work, as long as PDO is enabled with MySQL support (unless you want to use a different db driver).
#16

[eluser]wiredesignz[/eluser]
Just to be clear, form (input) validation in the controller is not the same thing as data validation in your model.

The controller checks and cleans the incoming data and ensures that each field meets a minimum requirement. It should not try to check if the data values are suitable for use by the application.

ie: A login form with username and password should be form validated only to ensure the fields exist and are minimum length etc. Your business logic in the model should then make the comparisons and verify the actual values submitted and give a result back the controller so it knows how to respond to the user input.
#17

[eluser]Burak Guzel[/eluser]
[quote author="wiredesignz" date="1258443459"]Just to be clear, form (input) validation in the controller is not the same thing as data validation in your model.

The controller checks and cleans the incoming data and ensures that each field meets a minimum requirement. It should not try to check if the data values are suitable for use by the application.

ie: A login form with username and password should be form validated only to ensure the fields exist and are minimum length etc. Your business logic in the model should then make the comparisons and verify the actual values submitted and give a result back the controller so it knows how to respond to the user input.[/quote]

Right, I see what you mean.

If you look at the Day4 article, you can see I created another class called Current_User, which encapsulates User.

It's responsible for authenticating the user, and also it contains an instance of the User object once the user is logged in. And it carries it over between page loads, by putting the user_id in the Session.

It's a Singleton pattern class, so it allows for the logged in User instance to be accessed like a global variable: Current_User::user();

Does that sound like what you are talking about?
#18

[eluser]M4rc0[/eluser]
lane4, do you think using doctrine would have any performance impact on CI?

Does anybody think this could slow it down a little?

I can see the benefits of using ORM, specially for large projects, but I'm not sure if the cost for it is worth it.
Can anybody share any opinions?
#19

[eluser]Burak Guzel[/eluser]
[quote author="M4rc0" date="1259107935"]lane4, do you think using doctrine would have any performance impact on CI?

Does anybody think this could slow it down a little?

I can see the benefits of using ORM, specially for large projects, but I'm not sure if the cost for it is worth it.
Can anybody share any opinions?[/quote]

It depends on how you use it. Sometimes it even improves performance:
http://www.doctrine-project.org/blog/tra...erformance

They have a manual section with optimization tips:
http://www.doctrine-project.org/document...erformance
#20

[eluser]jwright[/eluser]
I've been really liking your tutorials and the CI/Doctrine combo.

Now I'm trying to get Doctrine into one of the CI module frameworks out there as a module ...

either using
http://codeigniter.com/wiki/Modular_Extensions_-_HMVC
or

http://codeigniter.com/wiki/Matchbox/

I've only tried Matchbox so far but if I use the approach to installing Doctrine in CI in your Day 1 tutorial, I get this ...

"An Error Was Encountered

Matchbox: Unable to load the requested file: plugins/doctrine_pi.php"

I guess it's time to start searching the logs.

I'm wondering if anyone else is interested in a Doctrine module for CI and if anyone has any best practice advice on how to accomplish it and use it from other modules.

Maybe I should start another thread about this.




Theme © iAndrew 2016 - Forum software by © MyBB