\Mos\DatabaseTSQLQueryBuilderBasic

Database wrapper, provides a database API for the framework but hides details of implementation.

Summary

Methods
Properties
Constants
getSQL()
setSQLDialect()
setTablePrefix()
createTable()
dropTable()
dropTableIfExists()
mapColumnsWithValues()
insert()
update()
delete()
select()
from()
join()
rightJoin()
leftJoin()
where()
andWhere()
groupBy()
orderBy()
limit()
offset()
No public properties found
No constants found
build()
clear()
No protected properties found
N/A
createJoin()
isAssoc()
$dialect
$sql
$prefix
$columns
$from
$join
$where
$groupby
$orderby
$limit
$offset
N/A

Properties

$dialect

$dialect : 

Properties

Type

$sql

$sql : 

Type

$prefix

$prefix : 

Type

$columns

$columns : 

Type

$from

$from : 

Type

$join

$join : 

Type

$where

$where : 

Type

$groupby

$groupby : 

Type

$orderby

$orderby : 

Type

$limit

$limit : 

Type

$offset

$offset : 

Type

Methods

getSQL()

getSQL() : string

Get SQL.

Returns

string —

as sql-query

setSQLDialect()

setSQLDialect(string  $dialect) : void

Set database type to consider when generating SQL.

Parameters

string $dialect

representing database type.

setTablePrefix()

setTablePrefix(string  $prefix) : void

Set a table prefix.

Parameters

string $prefix

to use in front of all tables.

createTable()

createTable(string  $name, array  $columns) : $this

Create a table.

Parameters

string $name

the table name.

array $columns

the columns in the table.

Returns

$this

dropTable()

dropTable(string  $name) : $this

Drop a table.

Parameters

string $name

the table name.

Returns

$this

dropTableIfExists()

dropTableIfExists(string  $name) : $this

Drop a table if it exists.

Parameters

string $name

the table name.

Returns

$this

mapColumnsWithValues()

mapColumnsWithValues(array  $columns, array|null  $values) : array

Create a proper column value arrays from incoming $columns and $values.

Parameters

array $columns
array|null $values

Returns

array —

that can be parsed with list($columns, $values)

insert()

insert(string  $table, array  $columns, array  $values = null) : void

Build a insert-query.

Parameters

string $table

the table name.

array $columns

to insert och key=>value with columns and values.

array $values

to insert or empty if $columns has both columns and values.

update()

update(string  $table, array  $columns, array  $values = null, array  $where = null) : void

Build an update-query.

Parameters

string $table

the table name.

array $columns

to update or key=>value with columns and values.

array $values

to update or empty if $columns has bot columns and values.

array $where

limit which rows are updated.

delete()

delete(string  $table, array  $where = null) : void

Build a delete-query.

Parameters

string $table

the table name.

array $where

limit which rows are updated.

select()

select(string  $columns = '*') : $this

Build a select-query.

Parameters

string $columns

which columns to select.

Returns

$this

from()

from(string  $table) : $this

Build the from part.

Parameters

string $table

name of table.

Returns

$this

join()

join(string  $table, string  $condition) : $this

Build the inner join part.

Parameters

string $table

name of table.

string $condition

to join.

Returns

$this

rightJoin()

rightJoin(string  $table, string  $condition) : $this

Build the right join part.

Parameters

string $table

name of table.

string $condition

to join.

Returns

$this

leftJoin()

leftJoin(string  $table, string  $condition) : $this

Build the left join part.

Parameters

string $table

name of table.

string $condition

to join.

Returns

$this

where()

where(string  $condition) : $this

Build the where part.

Parameters

string $condition

for building the where part of the query.

Returns

$this

andWhere()

andWhere(string  $condition) : $this

Build the where part with conditions.

Parameters

string $condition

for building the where part of the query.

Returns

$this

groupBy()

groupBy(string  $condition) : $this

Build the group by part.

Parameters

string $condition

for building the group by part of the query.

Returns

$this

orderBy()

orderBy(string  $condition) : $this

Build the order by part.

Parameters

string $condition

for building the where part of the query.

Returns

$this

limit()

limit(string  $condition) : $this

Build the LIMIT by part.

Parameters

string $condition

for building the LIMIT part of the query.

Returns

$this

offset()

offset(string  $condition) : $this

Build the OFFSET by part.

Parameters

string $condition

for building the OFFSET part of the query.

Returns

$this

build()

build() : string

Build SQL.

Returns

string —

as SQL query

clear()

clear() : void

Clear all previous sql-code.

createJoin()

createJoin(string  $table, string  $condition, string  $type) : void

Create a inner or outer join.

Parameters

string $table

name of table.

string $condition

to join.

string $type

what type of join to create.