I'm looking for Ruby's Active record for PHP. Something that is so simple that I just define my fields, extend the base ORM class, and I get ACID operations for free. I should get default getters and setters without writing any code, but overriding a default getter or setter is as easy as declaring get$fieldName or set$fieldName functions with the behavior I want. Symphony makes you create about 5 files per object, and all defined objects always load as far as I can tell. What is a better alternative? Why is it better? Can you put simple examples in your answers please?
Doctrine is another ORM I've looked at besides symphony . There also you need to create yaml files that describe your data structures. The database already defines this stuff. What will just read my table defs without having to generate and store config files everywhere?
Propel is an open-source Object-Relational Mapping (ORM) for SQL-Databases in PHP 5.5. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.
ORM (Object-relational mapping), also known as O/RM, and O/R mapping is a programming approach for converting data between incompatible type systems. Many full stack frameworks provide their own database abstraction approaches or ORMs.
A lightweight and easy-to-use ORM for CodeIgniter. Gas was built specifically for CodeIgniter app. It uses CodeIgniter Database packages, a powerful DBAL which support numerous DB drivers. Gas ORM provide a set of methods that will map your database tables and its relationship, into accessible object.
PDO and ORM are two entirely different things. PDO is a specific implementation of a Database Access Abstraction Layer, it enables you to connect, run SQL and retrieve results from the database with an API that is consistent across different database backends (e.g. MySQL, PostgreSQL, MS SQL, etc.)
I'm a big fan of Doctrine which is a full featured ORM that will be replacing Propel as Symfony's default ORM.
It's got your basic ORM stuff you'd expect along with a full featured query builder that I've found to be wonderful.
It comes with a full suite of command line tools to manage your databases. For example, you can create your schemas and fixtures in YAML, have Doctrine generate classes based on your Schema, create the database, create the schema based on the models, then populate the database with your fixtures all with a single ./doctrine build-all-reload
.
It also includes support for database migrations and recently updated the migrations to automatically diff and generate your migration models.
As per your doctrine complaints, you can run a command ./doctrine generate-models-db
or ./doctrine generate-yaml-db
to automatically create models and yaml files respectively from your current database setup.
Other niceties include "Behaviors" which makes life much easier when implementing certain, well, behaviors in your schema. For example you can add the "Timestampable" behavior to your class file. Doctine automatically adds a 'created_at' and 'updated_at' column, populates them, and every $object->save()
you run automatically updates the 'updated_at' column. More complex behaviors include i18n, table versioning, and trees (though really only NestedSet).
Personally I've been extremely enamored with Doctrine and rave about it every chance I get.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With