I have been working on a relational data base with Codeigniter and found out that DataMapper is useless for serious project. Codeigniter’s Active record is useless as it is not providing a many to many or one to many methodology as well. DataMapper is slow and non configurable!
- It loads the whole table to an object when you query.
- When you put “A” in the first time the second time you put an “A” you will have 2 As in the data base. It does not have the Ignore
option like SQL.And you have to query for an item to see if it exists, if not, then Insert it. - They did a lot coding for it but it does not seem to be any good for making a huge data base
- It is not fast for querying.
Is that seem to be the consensus among the community. Do you recommend using pure mysql in the php to do operations on many to many and one to many? Or do you think I am wrong! Please feel free to advise me on that.
My question is what do you use to do your data base with as a professional web designer?
Bit of an odd statement.
You define your requirements, and then select the tools that meet those requirements, not the other way around.
Datamapper is an ORM, an Object Relational Mapper. In this case one that follows the Active Record design pattern (do not confuse this with CI’s AR, which is no active record, it’s a query builder). It will map a data entity (in this case a record in an RDBMS table) to an object, and it is aware of the relationships between those objects.
It is what an ORM does. Is it slower than using PHP’s native functions to directly access the database? Absolutely. Any level of abstraction added will add processing time.
It is not the goal of an ORM to be the fastest in data manipulation, it is the goal to abstract your data manipulation from your controller logic, which makes it easier and quicker to write applications, and absolutely faster to maintain such applications. As in a business context time == money, this is where the benefits are. If you code for free and run your code on a two-bit shared host, then maybe an ORM is not for you.
Also, an ORM is not a swiss army knife. It is designed for a specific purpose, which is an object oriented approach to data collections, and to manipulate those collections and their relationships.
Do not use it if it is not the correct tool for the job. If you need to mass update a million records based on some weird criteria, write a native SQL query instead. Do that in a custom model method to keep your data manipulation code abstracted from your controller.
As to your specific comments:
If you are a professional web designer, you should be aware of the proper way to design and build an application using an MVC architecture, and use the right toolset for the job so that you can deliver an application to your client in a timely fasion.
time == money, and if you can deliver faster, and you can maintain or improve faster, you’ll retain your customers. An ORM can help you with that. But do not use it for what it is not meant to do.