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.
Property | Type | Description |
---|---|---|
$driver | string |
string
|
$db | Illuminate\Database\DatabaseManager |
Illuminate\Database\DatabaseManager
|
public
cast (string $sql, string $asType = "INTEGER"
)
: string
Some drivers require same-type comparisons.
Property | Type | Description |
---|---|---|
$sql | string |
string
|
$asType | string |
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.
Property | Type | Description |
---|---|---|
$table | string |
string
|
$columns | string | array |
string | array
Column name(s). Defaults to ['created_at', 'updated_at'] |
public disableStrictMode ()
Used to disable strict mode during migrations
public getDriver () : string
Returns the driver name as a string, eg: pgsql
public getTablePrefix () : string
Get the table prefix.
public parse (string $sql) : string
Transforms an SQL statement to match the active driver.
Property | Type | Description |
---|---|---|
$sql | string |
string
|
public parseBooleanExpression (string $sql) : string
Transforms true|false expressions in a statement.
Property | Type | Description |
---|---|---|
$sql | string |
string
|
public parseConcat (string $sql) : string
Transforms CONCAT statement.
Property | Type | Description |
---|---|---|
$sql | string |
string
|
public parseGroupConcat (string $sql) : string
Transforms GROUP_CONCAT statement.
Property | Type | Description |
---|---|---|
$sql | string |
string
|
public parseIfNull (string $sql) : string
Transforms IFNULL statement.
Property | Type | Description |
---|---|---|
$sql | string |
string
|
public raw (string $sql) : mixed
Transforms and executes a raw SQL statement
Property | Type | Description |
---|---|---|
$sql | string |
string
|