Download the PHP package php-patterns/activerecord without Composer
On this page you can find all versions of the php package php-patterns/activerecord. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-patterns/activerecord
More information about php-patterns/activerecord
Files in php-patterns/activerecord
Package activerecord
Short Description php-activerecord is an open source ORM library based on the ActiveRecord pattern.
License MIT
Homepage http://www.phpactiverecord.org/
Informations about the package activerecord
PHP ActiveRecord
We encourage pull requests, and issues will be dealt with thoroughly and in a timely manner.
http://php-activerecord.github.io/activerecord/
Installation
Via composer:
Introduction
A brief summarization of what ActiveRecord is:
Active record is an approach to access data in a database. A database table or view is wrapped into a class, thus an object instance is tied to a single row in the table. After creation of an object, a new row is added to the table upon save. Any object loaded gets its information from the database; when an object is updated, the corresponding row in the table is also updated. The wrapper class implements accessor methods or properties for each column in the table or view.
More details can be found here.
This implementation is inspired and thus borrows heavily from Ruby on Rails' ActiveRecord. We have tried to maintain their conventions while deviating mainly because of convenience or necessity. Of course, there are some differences which will be obvious to the user if they are familiar with rails.
Minimum Requirements
Supported Databases
- MySQL
- PostgreSQL
- SQLite
Features
- Callbacks
- Model Caching
- Database adapter plugins
- Finder methods, static and dynamic
- Relationships
- Serializations (json/xml)
- Transactions
- Validations
- Writer methods
- Miscellaneous options such as: aliased/protected/accessible attributes
Installation
Setup is very easy and straight-forward. There are essentially only two configuration points you must concern yourself with:
- Configuring your database connections.
- Setting the database connection to use for your environment.
Example:
Once you have configured these settings you are done. ActiveRecord takes care of the rest for you. It does not require that you map your table schema to yaml/xml files. It will query the database for this information and cache it so that it does not make multiple calls to the database for a single schema.
Basic CRUD
Retrieve
These are your basic methods to find and retrieve records from your database. See the Finders section for more details.
Create
Here we create a new post by instantiating a new object and then invoking the save() method.
Update
To update you would just need to find a record first and then change one of its attributes. It keeps an array of attributes that are "dirty" (that have been modified) and so our sql will only update the fields modified.
Delete
Deleting a record will not destroy the object. This means that it will call sql to delete the record in your database but you can still use the object if you need to.
Contributing
Please refer to CONTRIBUTING.md for information on how to contribute to PHP ActiveRecord.