PHPackages                             carry0987/sanite - 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. carry0987/sanite

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

carry0987/sanite
================

A PHP library that provide base CRUD structure and methods, using PDO.

1.3.10(4mo ago)01343MITPHPPHP &gt;=8.0CI passing

Since Nov 30Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/carry0987/Sanite)[ Packagist](https://packagist.org/packages/carry0987/sanite)[ RSS](/packages/carry0987-sanite/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (24)Used By (3)

Sanite
======

[](#sanite)

[![Packgist](https://camo.githubusercontent.com/f2d128d1f2cc86be363d0f4f0e388efd4cdc9e2afbe884fe9ef27d531a901110/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6361727279303938372f73616e6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/carry0987/sanite)[![CI](https://github.com/carry0987/Sanite/actions/workflows/php-unit.yml/badge.svg)](https://github.com/carry0987/Sanite/actions/workflows/php-unit.yml/badge.svg)
Sanite is a PHP library that provide base CRUD structure and methods, using PDO.

Getting Started
---------------

[](#getting-started)

Make sure you have `Sanite` installed. If not, you can install it with the following command:

```
composer require carry0987/sanite
```

After installation, you can include `Sanite` in your project and start using it.

Establishing a Database Connection
----------------------------------

[](#establishing-a-database-connection)

Use `Sanite` to establish a database connection:

```
use carry0987\Sanite\Sanite;

// Database connection settings
$config = array(
    'host' => 'mariadb',
    'database' => 'dev_sanite',
    'username' => 'test_user',
    'password' => 'test1234',
    'port' => 3306, // Optional
    'charset' => 'utf8mb4' // Optional
);

// Create a database connection
$sanite = new Sanite($config);
```

Using a Data Model
------------------

[](#using-a-data-model)

Create your own data models to perform CRUD operations. Here's an example of using `UserModel` to retrieve user data.

First, ensure your model extends `DataReadModel` (or corresponding `DataCreateModel`, `DataDeleteModel`, `DataUpdateModel`):

```
namespace carry0987\Sanite\Example;

use carry0987\Sanite\Models\DataReadModel;

class UserModel extends DataReadModel
{
    // Implement your methods, for example:
    public function getUserById(int $userId)
    {
        $queryArray = [
            'query' => 'SELECT * FROM user WHERE uid = ? LIMIT 1',
            'bind'  => 'i',  // This value needs to be relative when using DBUtil::getPDOType
        ];
        $dataArray = [$userId];

        return $this->getSingleData($queryArray, $dataArray);
    }

    public function getAllUsers()
    {
        $queryArray = [
            'query' => 'SELECT * FROM user'
        ];

        return $this->getMultipleData($queryArray);
    }
}
```

Then, you can use your model like so:

```
use carry0987\Sanite\Example\UserModel;

// Instantiate UserModel
$userModel = new UserModel($sanite);

// Retrieve user information for user with ID 1
$user = $userModel->getUserById(1);
$users = $userModel->getAllUsers();

print_r($user);
print_r($users);
```

Exception Handling
------------------

[](#exception-handling)

`Sanite` defines a specific exception class `DatabaseException`. Capture and handle it appropriately in your code:

```
try {
    // ... attempt some database operations ...
} catch (\carry0987\Sanite\Exceptions\DatabaseException $e) {
    // ... handle database exception ...
    echo "Error: " . $e->getMessage();
}
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance74

Regular maintenance activity

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Recently: every ~138 days

Total

23

Last Release

144d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.2

1.1.5PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f43bad259478092c4ff269518aa9a0c8e91a537a67272877041b4bc1f25cfe8?d=identicon)[carry0987](/maintainers/carry0987)

---

Top Contributors

[![carry0987](https://avatars.githubusercontent.com/u/12984973?v=4)](https://github.com/carry0987 "carry0987 (41 commits)")

---

Tags

cruddatabasepdophp8

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/carry0987-sanite/health.svg)

```
[![Health](https://phpackages.com/badges/carry0987-sanite/health.svg)](https://phpackages.com/packages/carry0987-sanite)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
