PHPackages                             agungdhewe/phpsqlutil - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. agungdhewe/phpsqlutil

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

agungdhewe/phpsqlutil
=====================

Utility for create SQL insert, update and delete

v1.2.2(1y ago)0621GPL-3.0-or-laterPHPPHP ^8.3

Since Oct 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/agungdhewe/phpsqlutil)[ Packagist](https://packagist.org/packages/agungdhewe/phpsqlutil)[ RSS](/packages/agungdhewe-phpsqlutil/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (1)

Php SQL Utility
===============

[](#php-sql-utility)

This library is used to simplify Insert, Update and Delete using SQL Command.

Add this library to your project

```
composer require agungdhewe/phpsqlutil

```

Example
-------

[](#example)

### Insert Data

[](#insert-data)

```
use AgungDhewe\PhpSqlUtil\SqlInsert;

// initialize database connection
$db = new PDO(...);

$obj = new stdClass();
$obj->bank_id = 'AAA';
$obj->bank_name = 'Test AAA';
$obj->country_id = 'ID';

$tablename = "mst_bank";
$cmd = new SqlInsert($tablename, $obj);

$sql = $cmd->getSqlString();
$stmt = $db->prepare($sql);
$params = $cmd->getParameter();
$stmt->execute($params);

```

If we want to insert new row, using previous initiation, we need only providing object that will represent new row:

```
$newdata = new stdClass();
$newdata->bank_id = 'BBB';
$newdata->bank_name = 'Test BBB';
$params = $cmd->getParameter($newdata);
$stmt->execute($params);

```

Update Data
-----------

[](#update-data)

```
use AgungDhewe\PhpSqlUtil\SqlInsert;

// initialize database connection
$db = new PDO(...);

$obj = new stdClass();
$obj->bank_id = 'AAA';
$obj->bank_name = 'Bank AAA';
$obj->bank_code = 'BBB-01';

$tablename = "mst_bank";

$cmd = new SqlUpdate($tablename, $obj, ['bank_id']);
$sql = $cmd->getSqlString();
$stmt = $db->prepare($sql);
$params = $cmd->getParameter();
$stmt->execute($params);

```

Delete Data
-----------

[](#delete-data)

```
use AgungDhewe\PhpSqlUtil\SqlDelete;

// initialize database connection
$db = new PDO(...);

$obj = new stdClass();
$obj->bank_id = 'AAA';
$cmd = new SqlDelete("mst_bank", $obj, ['bank_id']);
$sql = $cmd->getSqlString();
$stmt = $db->prepare($sql);
$params = $cmd->getKeyParameter();
$stmt->execute($params);

```

Check existing data and update
------------------------------

[](#check-existing-data-and-update)

```
use AgungDhewe\PhpSqlUtil\SqlDelete;

// initialize database connection
$db = new PDO(...);

$cmd = new SqlSelect("mst_bank", ['bank_id']);
$sql = $cmd->getSqlString();
$stmt = $db->prepare($sql);

$key = new stdClass();
$key->bank_id = 'AAA';
$params = $cmd->getKeyParameter($key);
$stmt->execute($params);
$row = $stmt->fetch();

// update data dari row
if ($row) {
	$obj = (object)$row;
	$cmd = new SqlUpdate("mst_bank", $obj, ['bank_id']);
	$sql = $cmd->getSqlString();
	$stmt = $db->prepare($sql);

	$newdata = new stdClass();
	$newdata->bank_name = 'Ini ganti nama bank';

	$params = $cmd->getParameter($newdata);
	$stmt->execute($params);
}

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

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 ~2 days

Total

4

Last Release

579d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7fdb99b014c020c5a07753790ea36dcbbfe2a3c117c3d266ddf086db51510ff6?d=identicon)[agung\_dhewe@yahoo.com](/maintainers/agung_dhewe@yahoo.com)

---

Top Contributors

[![agungdhewe](https://avatars.githubusercontent.com/u/16076253?v=4)](https://github.com/agungdhewe "agungdhewe (12 commits)")

### Embed Badge

![Health badge](/badges/agungdhewe-phpsqlutil/health.svg)

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

PHPackages © 2026

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