PHPackages                             vovanmix/web\_orm - 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. vovanmix/web\_orm

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

vovanmix/web\_orm
=================

simple lightweight ORM for MySQL written on PHP

18PHP

Since Jun 13Pushed 10y ago1 watchersCompare

[ Source](https://github.com/vovanmix/web_orm)[ Packagist](https://packagist.org/packages/vovanmix/web_orm)[ RSS](/packages/vovanmix-web-orm/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#Simple MySQL ORM [![Build Status](https://camo.githubusercontent.com/d9934e67c8f22663e4466ed7ebe234b6ae079499af95c1cad30087dc55f78946/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f766f76616e6d69782f7765625f6f726d2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vovanmix/web_orm/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/b0395c5ed9c290e2313a8b51f555e3b76d2bdd8f2f4841230d489cfa5e696200/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f766f76616e6d69782f7765625f6f726d2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/vovanmix/web_orm/?branch=master)

This project is a simple lightweight ORM for MySQL written on PHP

It works with PHP 5.3+ and MySQL with PDO\_MYSQL for PHP enabled

\##Install Install via Composer:

```
"vovanmix/web_orm": "dev-master"

```

\##Usage

To use it, simply include the class file and create an instance:

```
require_once("ormPDOClass.php");
// OR
// use Vovanmix\WebOrm\ormPDOClass;
$config = array(
	'host' => $HOST,
	'base' => $DATABASE_NAME,
	'user' => $USER,
	'password' => $PASSWORD,
	'socket' => $SOCKET //optional
);
$ORM = new ormPDOClass($config);

```

\##Searching After that, you can use the object to search:

```
$foundRecords = $ORM->find('all', 'table1', [
	'conditions' => [
		['table1.field1', '>' 12],
		['table1.field2', '=' [1, 2, 3]],
		'OR' => [
			['table1.field3', '!=', NULL],
			['table1.field4', '.=', 'table1.field5']
		]
	],
	'joins' => [
		['table2', [
			['table2.field1', '.=', 'table1.field5']
		]]
	],
	'fields' => [
		'table2.field1' => 'Name',
		'table1.field5' => 'Value'
	],
	'limit' => 10,
	'order' => [
		'table1.field1' => 'asc',
		'table1.field2' => 'desc'
	]
]);

```

This will execute the following SQL query:

```
SELECT table2.field1 as Name, table1.field5 as Value FROM table1
LEFT JOIN table2 ON table2.field1 = table1.field5
WHERE table1.field1 > 12 AND table1.field2 IN (1, 2, 3) AND (table1.field3 IS NOT NULL OR table1.field4 = table1.field5)
ORDER BY table1.field1 asc, table1.field2 desc
limit 10

```

You can use several types of find queries: `all` will return array of all found records, `first` will return first found record, `list` will return all records in the following format: first value in the "fields" setting as key, and the second as value

Also you can use a magic functions to run Find:

```
$user = $ORM->getById('users', 1);
//is equal to $ORM->find('first', 'users', ['conditions' => [['id', '=', 1]]]);
$users = $ORM->findByCity('users', 'Los Angeles');
//is equal to $ORM->find('all', 'users', ['conditions' => [['city', '=', 'Los Angeles']]]);

```

\##Other operations You can use the object to insert, it will return the ID of the inserted record

```
$ID = $ORM->save('advert_logs', [
	'advert_id' => $id,
	'price' => $advert['price'],
	'time' => date('Y-m-d H:i:s'),
	'operation' => $operation,
	'comment' => $comment,
	'state' => $new_state,
]);

```

You can use the object to update, it will return count of updated records

```
$updatedCount = $ORM->update('user', [
		'last_activity' => date('Y-m-d H:i:s')
	],
	[
		['id', '=', $user_id]
	]
);

```

You can use the object to delete, it will return count of deleted records

```
$ORM->remove('variants', [
	['user_id', '=', $user_id],
	['advert_id', '=', $id],
	['demand_id', '=', $current_demand]
]);

```

\##Models You can simplify your code by omitting table names with the help of Models. You need to include a model class and create a new instance:

```
//include main class and create instance as usual
require_once("model.php");
// OR
// use Vovanmix\WebOrm\Model;
$userModel = new Model( false, 'user', $ORM->connection );
//or
$userModel = new Model( $config, 'user' );
$user = $userModel->getById(1);

```

\##Debugging There are several parameters for debugging:

```
$ORM->debug = true;

```

Is used to output all queries that will be executed

```
$ORM->print_errors = true;

```

Is used for printing all errors found while executing

```
$ORM->fictive = true;

```

Is used for just printing, but not executing queries

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![vovanmix](https://avatars.githubusercontent.com/u/7279514?v=4)](https://github.com/vovanmix "vovanmix (65 commits)")

### Embed Badge

![Health badge](/badges/vovanmix-web-orm/health.svg)

```
[![Health](https://phpackages.com/badges/vovanmix-web-orm/health.svg)](https://phpackages.com/packages/vovanmix-web-orm)
```

###  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)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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