Rocks (PHP)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Stable release
0.2.1 / May 29, 2009 (2009-05-29)
Written in PHP
Operating system Cross-platform
Type Object-relational mapping and web development framework
License GNU General Public License

The Rocks Library contains a database independent object-relational mapper (ORM) for PHP 5.1 plus, allowing easy access to all types of database.

However the Rocks Framework also includes other functionality such as a templated system for producing web pages, which encaspulates general web development problems.


This is an open source project hosted on SourceForge the development team mainly consists of volunteers. Currently this framework is in alpha testing.

Usage demonstration[edit]

This is similar to the active record pattern with one class corresponding to one table in the database however it is slightly different in that each class maps dynamically to the table.

Although as of version 0.02 multiple classes can now be returned using the RocksDBOArray class.

$user = new RocksDBO("user");
$user->username = "John.Smith";

This selects a user with the username value of John. Smith if more than one record is returned an exception will be thrown. A record can be saved like so:

$user = new RocksDBO("user");
$user->firstname = "John";
$user->surname = "Smith";

Due to the dynamic nature of Rocks you can specify as many fields as you like in a class. For instance in the example above a field called age could also be provided but unless there is a corresponding field in the database table this will not be saved or updated from data in the database.

One of the features this library supports is the lack of configuration. All the library needs to know is the database connection parameters it is connecting to and it will configure itself.

External links[edit]