PHPackages                             its-mieger/lara-db-ext - 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. its-mieger/lara-db-ext

Abandoned → [mehr-it/lara-db-ext](/?search=mehr-it%2Flara-db-ext)Library[Database &amp; ORM](/categories/database)

its-mieger/lara-db-ext
======================

Extension to laravel's database and ORM features, including model joins (SQL), multi column queries and prefixing for database fields

2.1.0(6y ago)0132[4 PRs](https://github.com/its-mieger/lara-db-ext/pulls)proprietaryPHP

Since Dec 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/its-mieger/lara-db-ext)[ Packagist](https://packagist.org/packages/its-mieger/lara-db-ext)[ RSS](/packages/its-mieger-lara-db-ext/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (26)Used By (0)

TODO: Readme must be completed
==============================

[](#todo--readme-must-be-completed)

### Custom connections

[](#custom-connections)

### selectPrefixed

[](#selectprefixed)

Sometimes you want certain column names to be prepended with a given prefix. Following example prefixes all returned column names with the `"user_"` prefix:

```
DB:table('users')->selectPrefixed(['id', 'name'], 'user_')->get();

// => [['user_id' => 1, 'user_name' => 'John']]

```

This becomes really useful when you're using joins on tables with conflicting column names:

```
DB:table('users')
	->join('children', 'users.id', '=', 'children.user_id')
	->addSelectPrefixed('users.*', 'user_')
	->addSelectPrefixed('children.*', 'child_')
	->get();

// => [[ 'user_id' => 1, 'user_name' => 'John', 'child_id' => 12, 'child_name' => 'Maria']]

```

Without prefixing, the `children` fields would silently overwrite the `users` fields. As you see it also works using wildcard column selectors. And the best: it does not produce an extra query to obtain the table structure. In fact it does not depend on table columns at all:

It can also be used with expressions:

```
DB:table('users')->selectPrefixed(new Expression('count(*) as myCount'), 'user_')->get();

// => [['user_myCount' => 123]]

```

You can also set multiple prefixes in one call if you omit the prefix parameter and pass an associative array as first parameter

```
DB:table('users')
	->join('children', 'users.id', '=', 'children.user_id')
	->selectPrefixed([
		'user_'  => 'users.*',
		'child_' => ['id', 'name'],
	])
	->get();

```

### whereNotNested

[](#wherenotnested)

If you want to negate a nested where clause, the new `whereNotNested` function comes in:

```
DB:table('users')
	->whereNotNested(function($query) {
		$query->where('name', 'John');
		$query->where('age', '>', 49);
	})
	->get();

```

This would produce following query:

```
SELECT * FROM users WHERE NOT (first_name = 'John' AND age > 49)

```

### whereMultiIn

[](#wheremultiin)

Some SQL dialects allow to compare multiple columns using the `IN` operator. You may use it using the `whereMultiIn` function:

```
DB:table('users')
	->whereMultiIn(['name', 'age'], [
		['John', 38],
		['Ida', 49],
	])
	->get();

```

This would produce following query:

```
SELECT * FROM users WHERE (name, age) IN ( ('John', 38), ('Ida', 49) )

```

You may even pass a sub select instead of a values array:

```
DB:table('users')
	->whereMultiIn(['name', 'age'], function ($query) {
		return $query->select(['parent_name', 'parent_age'])
			->from('children')
			->where('age', 'whereMultiColumns(['name', 'age'], '!=', ['n', 'a'])
	->get();

```

This would produce following query:

```
SELECT * FROM users WHERE NOT (name = n AND age = a)

```

### Automatic where detection

[](#automatic-where-detection)

Another improvement is that the `where` functions now can be used with an array as values parameter, so it get's automatically converted to `whereIn`. Of course this also works with multiple columns:

```
DB:table('users')
	->where('name', ['John', 'Ida'])
	->get();

DB:table('users')
	->where(['name', 'age'], [
		['John', 38],
		['Ida', 49],
	])
	->get();

```

This works also for the `whereColumn` functions:

```
DB:table('users')
	->whereColumn(['name', 'age'], ['n', 'a'])
	->get();

```

Timezone handling
-----------------

[](#timezone-handling)

Time zone handling in database can be complicated. Laravel passes dates without timezone information to the database. This behavior is correct as the data is usually stored without any timezone information. When reading dates, Laravel (Eloquent) interprets dates using the default application timezone.

But Laravel does not ensure that DateTime parameters are using the application timezone when passing them to the database. So if you pass a date with a different timezone to database, it will be interpreted using another timezone on reading.

To ensure all DateTime parameters are converted to application timezone before sending them to database, this package adds the "adapt\_timezone" configuration option for database connections. If set to true, any DateTime values will be converted to the application timezone before passing them to the database.

The `AdaptsAttributeTimezone` trait implements the timezone adaption for Eloquent model attributes.

### Database session timezone

[](#database-session-timezone)

Some databases, such as MySQL use the database session timezone when converting dates to timestamps (see [MySQL Documentation for details](https://dev.mysql.com/doc/refman/8.0/en/datetime.html)). For MySQL this does only affect storing dates to TIMESTAMP columns (not for DATETIME columns) and NOW() and CURTIME() functions. Therefore you should always configure the "timezone" parameter for connections to the same value as the application timezone!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity71

Established project with proven stability

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

Recently: every ~37 days

Total

21

Last Release

2274d ago

Major Versions

1.14.0 → 2.0.02019-10-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4062a57c91cdead9169f9e84797ada75bc2df8867a632d11521dbbff9e3231a?d=identicon)[its-mieger](/maintainers/its-mieger)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/its-mieger-lara-db-ext/health.svg)

```
[![Health](https://phpackages.com/badges/its-mieger-lara-db-ext/health.svg)](https://phpackages.com/packages/its-mieger-lara-db-ext)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[abbasudo/laravel-purity

elegant way to add filter and sort in laravel

514330.5k1](/packages/abbasudo-laravel-purity)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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