I started my app very simply following the documentation videos for Codeigniter.
I have the following tables:
Account
account_id
name
details
Contact
contact_id
account_id
name
address
Order
order_id
account_id
contact_id
date
开发者_如何学编程 description
Item
item_id
order_id
description
price
Relationships are as follows: 1 Account to many orders 1 Account to many contacts 1 Contact to many orders 1 Order to many items
Now when I'm trying to get the account name from a view that's only passed a query from an order table, the queries can get a bit cumbersome.
In saying that, the app is quite simple and there's not too many of these queries.
I just want to know what your opinions are on ORMs - do you think one is necessary for a simple app like this?
I'm not sure what constraints your framework places on your ability to write SQL, but no, you don't need an ORM.
SQL is a very simple language to write powerful queries in. For a simple application like you are talking about, all the more so.
With frameworks, MVC, ORM, ABC, FBI, etc... you can end up spending more time satisfying the framework dependencies than it saves you, ending up with a complicated mess, when the intent was to save time and simplify.
Don't forget how competent a set of UI scripts and a few static classes can be in PHP.
I would just stick with CodeIgniter's built in ActiveRecord. Any more abstraction between you are the database would be serious overkill for such simple data.
Codeigniter's Active Record is a good compromise: you don't need to map all your database schema to classes, but you get a convenient interface that takes care of some things for you. I think it's well suited for your situation.
精彩评论