The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Laravel Mariadb

ybr-nx/laravel-mariadb image

Laravel Mariadb stats

Downloads
298.1K
Stars
95
Open Issues
5
Forks
6

View on GitHub →

Add MariaDB JSON select support to Laravel

laravel-mariadb

Add MariaDB JSON support to Laravel. Requires at least MariaDB 10.2.3 (and 10.2.7 to use ->json() migrations)

Install

Using composer:

$ composer require ybr-nx/laravel-mariadb

Configure (only Larvel 5.3 and 5.4)

Include MariaDBServiceProvider in your config/app.php:

'providers' => [
/*
* Package Service Providers...
*/
YbrNX\MariaDB\MariaDBServiceProvider::class,
]

set driver in database configuration to mariadb

'defaultconnection' => [
'driver' => 'mariadb',

Added functionality

Migration

Adds needed validation to json fields during migrations

$table->json('field') //CHECK (JSON_VALID(field))
$table->json('field')->nullable() //CHECK (field IS NULL OR JSON_VALID(field))
Query builder

Builds json select statements to work with MariaDB

$query->where('somejson->something->somethingelse', 2)
DB::table('sometable')->select('sometable.somedata', 'sometable.somejson->somedata as somejsondata')

And also JSON_SET() works in MariaDB as in MySQL 5.7

DB::table('sometable')->where('somejson->somedata', $id)->update(['somejson->otherdata' => 'newvalue']);

NB There is bug in MariaDB < 10.2.8 JSON_EXTRACT() behaviour function. It's fixed in MariaDB 10.2.8: https://jira.mariadb.org/browse/MDEV-12604

//works with string in MySQL & MariaDB 10.2.8
$query->where('somejson->something->somethingelse', 'somedata')
 
//works with string in MariaDB < 10.2.8
$query->where('somejson->something->somethingelse', '"somedata"')
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Ybr Nx Laravel Mariadb Related Articles

Cache Failover and Deferred Queue in Laravel 12.35 image

Cache Failover and Deferred Queue in Laravel 12.35

Read article
The Hidden Cost of MySQL Defaults in Laravel Apps image

The Hidden Cost of MySQL Defaults in Laravel Apps

Read article
Model Resource Helper Functions in Laravel 12.7 image

Model Resource Helper Functions in Laravel 12.7

Read article
Harnessing Full-Text Search in Laravel image

Harnessing Full-Text Search in Laravel

Read article
Laravel Prompts Adds a Multi-line Textarea Input, Laravel 11.3 Released image

Laravel Prompts Adds a Multi-line Textarea Input, Laravel 11.3 Released

Read article
Laravel 10.40 - With a Number Clamp Method, an APA-Style Helper, Vite Asset Path Customization, and More image

Laravel 10.40 - With a Number Clamp Method, an APA-Style Helper, Vite Asset Path Customization, and More

Read article
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
DreamzTech logo

DreamzTech

Hire 6-10+ Yrs. experienced skilled Laravel Developers from DreamzTech. We ensure NDA protected, 100% quality delivery. Contact Us & Discuss Your Need.

DreamzTech