sqlsrvDbTools

Extends \jDbTools

Provides utilities methods for a database

package

jelix

Methods

__construct

__construct(\jDbConnection $connector = null) 
inherited

Arguments

$connector

\jDbConnection

the connection to a database

Enclose the field name

encloseName(string $fieldName) : string
inherited
since 1.2

Arguments

$fieldName

string

the field name

Response

string

the enclosed field name

escapeValue

escapeValue(string $unifiedType, mixed $value,  $checkNull = false,  $toPhpSource = false) : string
inherited
since 1.2

Arguments

$unifiedType

string

the unified type name

$value

mixed

the value

$checkNull

$toPhpSource

Response

string

the value which is ready to include a SQL query string

execSQLScript

execSQLScript( $file) 
inherited

Arguments

$file

extractDateConverter

extractDateConverter( $parametersString) 
inherited

Arguments

$parametersString

getBooleanValue

getBooleanValue(string|boolean $value) : string
inherited
since 1.2

Arguments

$value

string|boolean

a value which is a boolean

Response

string

the string value representing a boolean in SQL

Retrieve the list of fields of a table

getFieldList(string $tableName, string $sequence = '', string $schemaName = '') : array<mixed,\jDbFieldProperties>
inherited abstract

Arguments

$tableName

string

the name of the table

$sequence

string

the sequence used to auto increment the primary key

$schemaName

string

the name of the schema (only for PostgreSQL)

Response

array<mixed,\jDbFieldProperties>

keys are field names

Give the expression that works with the target database, corresponding to the given function name

getNativeSQLFunction(string $name, string|null $parametersString = null) : string
inherited

Arguments

$name

string

a SQL function, maybe a SQL function of another database type

$parametersString

string|null

parameters given to the function. Null if no parenthesis

Response

string

the SQL expression, possibly with a native SQL function corresponding to the given foreign SQL function

getSQLColumnsList

getSQLColumnsList(array<mixed,string> $columns) : string
inherited
since 1.6.16

Arguments

$columns

array<mixed,string>

list of column names

Response

string

the list in SQL

returns the list of tables

getTableList() : array
inherited
Throws
\jException

Response

array

list of table names

Get informations about the given SQL type

getTypeInfo(string $nativeType) : array
inherited
since 1.2

Arguments

$nativeType

string

the SQL type

Response

array

an array which contains characteristics of the type array ( 'nativetype', 'corresponding unifiedtype', minvalue, maxvalue, minlength, maxlength) minvalue, maxvalue, minlength, maxlength can be null.

Insert several records into a table

insertBulkData(string $tableName, array<mixed,string> $columns, array<mixed,mixed[]> $data, string|array<mixed,string>|null $primaryKey = null, integer $options) : integer
inherited
since 1.6.16

Arguments

$tableName

string

$columns

array<mixed,string>

the column names in which data will be inserted

$data

array<mixed,mixed[]>

the data. each row is an array of values. Values are in the same order as $columns

$primaryKey

string|array<mixed,string>|null

the column names that are the primary key. Don't give the primary key if it is an autoincrement field, or if option is not IBD_*_IF_EXIST

$options

integer

one of IDB_* const

Response

integer

number of records inserted/updated

Parse a SQL CREATE TABLE statement and returns all of its components separately.

parseCREATETABLE( $createTableStatement) : array|boolean
inherited
since 1.6.16

Arguments

$createTableStatement

Response

array|boolean

false if parsing has failed. Else an array : 'name' => the schema/table name, 'temporary'=> true if there is the temporary keywork , 'ifnotexists' => true if there is the IF NOT EXISTS statement, 'columns' => list of columns definitions, 'constraints' => list of table constraints definitions, 'options' => all options at the end of the CREATE TABLE statement.

parseSQLFunctionAndConvert

parseSQLFunctionAndConvert( $expression) 
inherited

Arguments

$expression

Parse a SQL type and gives type, length.

parseSQLType(string $type) : array
inherited

..

Arguments

$type

string

Response

array

[$realtype, $length, $precision, $scale, $otherTypeDef]

stringToPhpValue

stringToPhpValue(string $unifiedType, string $value,  $checkNull = false) : string
inherited
since 1.2

Arguments

$unifiedType

string

the unified type name

$value

string

the value

$checkNull

Response

string

the php value corresponding to the type

Return the PHP type corresponding to the given unified type

unifiedToPHPType(string $unifiedType) : string
inherited
since 1.2
Throws
\Exception

Arguments

$unifiedType

string

Response

string

the php type

Constants

IBD_NO_CHECK

IBD_NO_CHECK
inherited

IBD_EMPTY_TABLE_BEFORE

IBD_EMPTY_TABLE_BEFORE
inherited

IBD_INSERT_ONLY_IF_TABLE_IS_EMPTY

IBD_INSERT_ONLY_IF_TABLE_IS_EMPTY
inherited

IBD_IGNORE_IF_EXIST

IBD_IGNORE_IF_EXIST
inherited

IBD_UPDATE_IF_EXIST

IBD_UPDATE_IF_EXIST
inherited

Properties

regular expression to detect comments and end of query

dbmsStyle : 
inherited

Type(s)

typesInfo

typesInfo : 
inherited

Type(s)

keywordNameCorrespondence

keywordNameCorrespondence : 
inherited

Type(s)

functionNameCorrespondence

functionNameCorrespondence : 
inherited

Type(s)

trueValue

trueValue : 
inherited

Type(s)

falseValue

falseValue : 
inherited

Type(s)

the database connector

_conn : \jDbConnection
inherited
var

Type(s)

\jDbConnection

unifiedToPhp

unifiedToPhp : 
inherited

Type(s)