PHPackages                             davewid/cactus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. davewid/cactus

ActiveLibrary[Database &amp; ORM](/categories/database)

davewid/cactus
==============

A lightweight ORM using the DataMapper pattern, PHP 5.3+

0.5.0(13y ago)1256[1 issues](https://github.com/daveWid/cactus/issues)MITPHPPHP &gt;=5.3

Since Jul 6Pushed 13y ago1 watchersCompare

[ Source](https://github.com/daveWid/cactus)[ Packagist](https://packagist.org/packages/davewid/cactus)[ Docs](https://github.com/daveWid/cactus)[ RSS](/packages/davewid-cactus/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Cactus
======

[](#cactus)

Cactus is a ORM using the DataMapper pattern for PHP 5.3+

Example
-------

[](#example)

We will walk through a quick example on how to use Cactus. First we will start with a table called `user` that we will build our example around.

```
CREATE TABLE IF NOT EXISTS `user` (
	`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
	`email` varchar(128) NOT NULL,
	`password` varchar(64) DEFAULT NULL,
	`first_name` varchar(50) NOT NULL,
	`last_name` varchar(50) NOT NULL,
	`status` tinyint(3) unsigned NOT NULL DEFAULT '1',
	`create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
	PRIMARY KEY (`user_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
```

Working with this structure we can now dive into the model and entity classes.

Mapper
------

[](#mapper)

The mapper classes hold all of the information about the database table it is mapping, including the table name and primary key.

Here is the model class for our `user` table.

```
