All Projects → SAM-IT → yii2-mariadb

SAM-IT / yii2-mariadb

Licence: MIT license
MariaDB Driver for Yii2

Programming Languages

PHP
23972 projects - #3 most used programming language
Dockerfile
14818 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to yii2-mariadb

yii2-content-tools
ContentTools editor implementation for Yii 2
Stars: ✭ 79 (+229.17%)
Mutual labels:  yii2
service-skeleton
Microservice skeleton based on yii2 framework.
Stars: ✭ 14 (-41.67%)
Mutual labels:  yii2
wnmp-dev
Development environment: Windows + nginx + MySQL + PHP
Stars: ✭ 52 (+116.67%)
Mutual labels:  mariadb
php-framework-benchmark
php framework benchmark (include laravel、symfony、silex、lumen、slim、yii2、tastphp etc)
Stars: ✭ 17 (-29.17%)
Mutual labels:  yii2
mqtt2sql
Copy MQTT topic payloads to MySQL/SQLite database
Stars: ✭ 54 (+125%)
Mutual labels:  mariadb
yii2-league-oauth2-server
Yii 2.0 implementation of PHP league OAuth2 server interfaces
Stars: ✭ 29 (+20.83%)
Mutual labels:  yii2
masking
Command line tool for generating anonymizing database from existed database
Stars: ✭ 67 (+179.17%)
Mutual labels:  mariadb
datastation
App to easily query, script, and visualize data from every database, file, and API.
Stars: ✭ 2,519 (+10395.83%)
Mutual labels:  mariadb
High-Traffic-wordpress-server-configuration
High Traffic WordPress server configuration Nginx (updated) PHP 7.4 PHP-fpm Mariadb (updated) Wordpress (updated) Cloudflare Full SSL
Stars: ✭ 31 (+29.17%)
Mutual labels:  mariadb
yii2-toastr
Yii2 - Javascript Toast Notifications
Stars: ✭ 25 (+4.17%)
Mutual labels:  yii2
antares
A modern, fast and productivity driven SQL client with a focus in UX.
Stars: ✭ 836 (+3383.33%)
Mutual labels:  mariadb
examination
Yii2-basic 考试系统
Stars: ✭ 76 (+216.67%)
Mutual labels:  yii2
mapet
Muitas pessoas tem bichinhos de estimação, entre eles os mais comuns são gatos e cachorros. Com a correria do dia a dia pode acontecer deles acabarem escapando, e ai aonde divulgar para ajudarem a encontrá-lo o mais rápido possível? Redes Sociais? WhatsApp? Pensando nisso criamos o mapet, um mapa que você indica aonde seu pet foi visto pela últi…
Stars: ✭ 15 (-37.5%)
Mutual labels:  mariadb
yii2-rollbar
Rollbar for Yii2
Stars: ✭ 36 (+50%)
Mutual labels:  yii2
yii2-imagick
Class for working with Imagick
Stars: ✭ 17 (-29.17%)
Mutual labels:  yii2
sea-query
🔱 A dynamic SQL query builder for MySQL, Postgres and SQLite
Stars: ✭ 595 (+2379.17%)
Mutual labels:  mariadb
yii2-array-query
Yii2 component that allows for searching/filtering the elements of an array.
Stars: ✭ 34 (+41.67%)
Mutual labels:  yii2
yii2-sweet-submit
sweet sumit using sweetalert
Stars: ✭ 26 (+8.33%)
Mutual labels:  yii2
yii2-datetime-widgets
Datetime widgets for Yii2
Stars: ✭ 22 (-8.33%)
Mutual labels:  yii2
luya-bootstrap4
Bootstrap4 Assets and Helper classes like ActiveForm for LUYA and Yii2.
Stars: ✭ 18 (-25%)
Mutual labels:  yii2

Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage Continous integration

yii2-mariadb

While Yii2 supports MariaDB through its MySQL driver, the differences between MariaDB and MySQL are increasing. At this time the driver included in Yii2 will not properly detect JSON columns in MariaDB and will not properly store data in them.

The goal of this library is to implement the MariaDB specific changes required to get all features working in MariaDB that are supported in the Yii2 core library for other DBMSes.

Tests

The tests coverage is really high due to 2 reasons:

  • All code extends their MySQL counter parts in the framework, only very little is added.
  • We run the core tests for Yii2 (with some minor changes) to guarantee interoperability with the framework.

Usage

To use the MariaDB Schema implementation there are several approaches.

Override the schema class used for MySQL

Update the schemaMap property in your Connection config (the drivername is still mysql since we use the MySQL PDO driver) (RECOMMENDED)

'db' => [
    'class' => Connection::class,
    'schemaMap' => [
        'mysql' => SamIT\Yii2\MariaDb\Schema::class
    ]
]

Add schema class to schemaMap

Append the new Schema class to the schemaMap property and set the driverName property manually.

'db' => [
    'class' => Connection::class,
    'driverName' => 'mariadb',
    'schemaMap' => [
        'mariadb' => SamIT\Yii2\MariaDb\Schema::class
    ]
]

JSON Column detection

Since MariaDB has no built-in JSON data type we need to do some extra work to detect JSON columns. We do this by parsing the SQL obtained when using SHOW CREATE TABLE. Since MariaDB supports CHECK constraints these are used to ensure a column can only contain valid JSON. Any constraint that of the form: json_valid(`column1`) will identify the column as JSON. Note that this could lead to problems if you have weird constraints, consider this:

`column1` longtext CHECK(not json_valid(`column1`));

Will mark column1 as a JSON column.

Column creation

When creating JSON columns the ColumnSchemaBuilder requires the name of the column to add the table constraint. Since this is not the case for all other column types Yii does not pass the name of the column to the builder. Consider this code, for example in a migration:

$this->alterColumn('{{test}}', 'field1', $this->json());

Here there is no way for the ColumnSchemaBuilder to know what the name of the column is going to be. Since the schema builder is ultimately passed to QueryBuilder::alterColumn(), we can intercept it there and replace the column name in the constraint.

If you coerce the ColumnSchemaBuilder to string early, or use it without the QueryBuilder you will end up with SQL like this:

ALTER COLUMN `field` JSON CHECK(json_valid({name}));

That will clearly not work. For those cases we have added a toString(string $columnName) method to the builder.

// Will result in broken SQL.
$this->alterColumn('{{test}}', 'field1', $this->json() . ' --APPEND SOMETHING');
// Will result in working SQL.
$this->alterColumn('{{test}}', 'field1', $this->json()->toString('field1') . ' --APPEND SOMETHING');
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].