PHPackages                             icehrm/php-active-record - 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. icehrm/php-active-record

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

icehrm/php-active-record
========================

Simple PHP library to access databases using active record pattern

1.1.0(3y ago)222[1 issues](https://github.com/thilinah/php-active-record/issues)MITPHPPHP &gt;=7.1

Since Jan 27Pushed 3y ago2 watchersCompare

[ Source](https://github.com/thilinah/php-active-record)[ Packagist](https://packagist.org/packages/icehrm/php-active-record)[ RSS](/packages/icehrm-php-active-record/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (3)Used By (0)

PHP Active Record
=================

[](#php-active-record)

Simple PHP library to access databases using active record pattern.

Installation
------------

[](#installation)

```
composer require icehrm/php-active-record
```

Usage
-----

[](#usage)

### Create a model

[](#create-a-model)

- Let's assume you have this example table (taken from [IceHrm](https://github.com/gamonoid/icehrm))

```
create table `Files` (
 `id` bigint(20) NOT NULL AUTO_INCREMENT,
 `name` varchar(100) NOT NULL,
 `filename` varchar(100) NOT NULL,
 `employee` bigint(20) NULL,
 `file_group` varchar(100) NOT NULL,
 `size` bigint(20) NULL,
 `size_text` varchar(20) NULL,
 primary key  (`id`),
 unique key `filename` (`filename`)
) engine=innodb default charset=utf8;
```

- Create a model class

```
