Dongle

Database driver dongle

 class Winter\Storm\Database\Dongle

This class uses regex to convert MySQL to various other drivers.

Properties

protected $db : Illuminate\Database\DatabaseManager

Database helper object

protected $driver : string

Driver to convert to: mysql, sqlite, pgsql, sqlsrv, postgis.

protected $strictModeDisabled : bool

Used to determine whether strict mode has been disabled.

Methods

public __construct (string $driver = "mysql", Illuminate\Database\DatabaseManager $db = null)

Constructor.

Parameters
Property Description
$driver
string
$db
Illuminate\Database\DatabaseManager
Returns
mixed

public cast (string $sql, string $asType = "INTEGER") : string

Some drivers require same-type comparisons.

Parameters
Property Description
$sql
string
$asType
string
Returns
string

public convertTimestamps (string $table, string | array $columns = null)

Alters a table's TIMESTAMP field(s) to be nullable and converts existing values.

This is needed to transition from older Laravel code that set DEFAULT 0, which is an invalid date in newer MySQL versions where NO_ZERO_DATE is included in strict mode.

Parameters
Property Description
$table
string
$columns
string | array

Column name(s). Defaults to ['created_at', 'updated_at']

Returns
mixed

public disableStrictMode ()

Used to disable strict mode during migrations

Returns
mixed

public getDriver () : string

Returns the driver name as a string, eg: pgsql

Returns
string

public getTablePrefix () : string

Get the table prefix.

Returns
string

public parse (string $sql) : string

Transforms an SQL statement to match the active driver.

Parameters
Property Description
$sql
string
Returns
string

public parseBooleanExpression (string $sql) : string

Transforms true|false expressions in a statement.

Parameters
Property Description
$sql
string
Returns
string

public parseConcat (string $sql) : string

Transforms CONCAT statement.

Parameters
Property Description
$sql
string
Returns
string

public parseGroupConcat (string $sql) : string

Transforms GROUP_CONCAT statement.

Parameters
Property Description
$sql
string
Returns
string

public parseIfNull (string $sql) : string

Transforms IFNULL statement.

Parameters
Property Description
$sql
string
Returns
string

public raw (string $sql) : mixed

Transforms and executes a raw SQL statement

Parameters
Property Description
$sql
string
Returns
mixed
Copyright © 2024 Winter CMS