Download the PHP package php-activerecord/php-activerecord without Composer
On this page you can find all versions of the php package php-activerecord/php-activerecord. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-activerecord/php-activerecord
More information about php-activerecord/php-activerecord
Files in php-activerecord/php-activerecord
Package php-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 php-activerecord
PHP ActiveRecord - Version 1.0
by
- @kla - Kien La
- @jpfuentes2 - Jacques Fuentes
- And these terrific Contributors
http://www.phpactiverecord.org/
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
- PHP 5.3+
- PDO driver for your respective database
Supported Databases
- MySQL
- SQLite
- PostgreSQL
- Oracle
Features
- Finder methods
- Dynamic finder methods
- Writer methods
- Relationships
- Validations
- Callbacks
- Serializations (json/xml)
- Transactions
- Support for multiple adapters
- Miscellaneous options such as: aliased/protected/accessible attributes
Installation
Setup is very easy and straight-forward. There are essentially only three configuration points you must concern yourself with:
- Setting the model autoload directory.
- Configuring your database connections.
- Setting the database connection to use for your environment.
Example:
Alternatively (w/o the 5.3 closure):
PHP ActiveRecord will default to use your development database. For testing or production, you simply set the default connection according to your current environment ('test' or 'production'):
Once you have configured these three 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.