include/database/SqlsrvManager.php
\SqlsrvManager
SQL Server (sqlsrv) manager
- Parent(s)
- \MssqlManager < \DBManager
Properties
$capabilities= 'array(
"affected_rows" => true,
'fulltext' => true,
'limit_subquery' => true,
'create_user' => true,
"create_db" => true,
)'
Capabilities this DB supports. Supported list: affected_rows Can report query affected rows for UPDATE/DELETE implement getAffectedRowCount() select_rows Can report row count for SELECT implement getRowCount() case_sensitive Supports case-sensitive text columns fulltext Supports fulltext search indexes inline_keys Supports defining keys together with the table auto_increment_sequence Autoincrement support implemented as sequence limit_subquery Supports LIMIT clauses in subqueries create_user Can create users for Sugar create_db Can create databases collation Supports setting collations disable_keys Supports temporarily disabling keys (for upgrades, etc.)
array(
"affected_rows" => true,
'fulltext' => true,
'limit_subquery' => true,
'create_user' => true,
"create_db" => true,
)
Details- Type
- n/a
$connectOptions= 'null'
null
Details- Type
- n/a
- Inherited_from
- \MssqlManager::$$connectOptions
resource
$database= 'null'
null
Details- Type
- resource
- Inherited_from
- \DBManager::$$database
- Inherited_from
- \MssqlManager::$$database
$date_formats= 'array(
'%Y-%m-%d' => 10,
'%Y-%m' => 7,
'%Y' => 4,
)'
array(
'%Y-%m-%d' => 10,
'%Y-%m' => 7,
'%Y' => 4,
)
Details- Type
- n/a
- Inherited_from
- \MssqlManager::$$date_formats
$dbType= ''mssql''
'mssql'
Details- Type
- n/a
- Inherited_from
- \MssqlManager::$$dbType
- See
- \DBManager::$dbType
$dieOnError= 'false'
Indicates whether we should die when we get an error from the DB
Inherited from: \DBManager::$$dieOnError\MssqlManager::$$dieOnErrorfalse
Details- Type
- n/a
- Inherited_from
- \DBManager::$$dieOnError
- Inherited_from
- \MssqlManager::$$dieOnError
$encode= 'true'
Indicates whether we should html encode the results from a query by default
Inherited from: \DBManager::$$encode\MssqlManager::$$encodetrue
Details- Type
- n/a
- Inherited_from
- \DBManager::$$encode
- Inherited_from
- \MssqlManager::$$encode
array
$index_descriptions= 'array()'
Index descriptions
Inherited from: \DBManager::$$index_descriptions\MssqlManager::$$index_descriptionsarray()
Details- Type
- array
- Inherited_from
- \DBManager::$$index_descriptions
- Inherited_from
- \MssqlManager::$$index_descriptions
string
$label= ''LBL_MSSQL_SQLSRV''
Driver name label, for install
'LBL_MSSQL_SQLSRV'
Details- Type
- string
$lastResult= ''
Registry of available result sets
Inherited from: \DBManager::$$lastResult\MssqlManager::$$lastResult- Type
- n/a
- Inherited_from
- \DBManager::$$lastResult
- Inherited_from
- \MssqlManager::$$lastResult
$last_error= 'false'
Last error message from the DB backend
Inherited from: \DBManager::$$last_error\MssqlManager::$$last_errorfalse
Details- Type
- n/a
- Inherited_from
- \DBManager::$$last_error
- Inherited_from
- \MssqlManager::$$last_error
\Logger
$log= ''
- Type
- \Logger
- Inherited_from
- \DBManager::$$log
- Inherited_from
- \MssqlManager::$$log
array
$maxNameLengths= 'array(
'table' => 128,
'column' => 128,
'index' => 128,
'alias' => 128
)'
array(
'table' => 128,
'column' => 128,
'index' => 128,
'alias' => 128
)
Details- Type
- array
- Inherited_from
- \MssqlManager::$$maxNameLengths
array
$options= 'array()'
array()
Details- Type
- array
- Inherited_from
- \DBManager::$$options
- Inherited_from
- \MssqlManager::$$options
$preparedTokens= 'array()'
Array of prepared statements and their correspoding parsed tokens
Inherited from: \DBManager::$$preparedTokens\MssqlManager::$$preparedTokensarray()
Details- Type
- n/a
- Inherited_from
- \DBManager::$$preparedTokens
- Inherited_from
- \MssqlManager::$$preparedTokens
int
$priority= '10'
DB driver priority Higher priority drivers override lower priority ones
10
Details- Type
- int
$queryCount= '0'
Current query count
Inherited from: \DBManager::$$queryCount\MssqlManager::$$queryCount0
Details- Type
- n/a
- Inherited_from
- \DBManager::$$queryCount
- Inherited_from
- \MssqlManager::$$queryCount
$queryLimit= '0'
Query threshold limit
Inherited from: \DBManager::$$queryLimit\MssqlManager::$$queryLimit0
Details- Type
- n/a
- Inherited_from
- \DBManager::$$queryLimit
- Inherited_from
- \MssqlManager::$$queryLimit
$query_time= '0'
Records the execution time of the last query
Inherited from: \DBManager::$$query_time\MssqlManager::$$query_time0
Details- Type
- n/a
- Inherited_from
- \DBManager::$$query_time
- Inherited_from
- \MssqlManager::$$query_time
$standardQueries= 'array(
'ALTER TABLE' => 'verifyAlterTable',
'DROP TABLE' => 'verifyDropTable',
'CREATE TABLE' => 'verifyCreateTable',
'INSERT INTO' => 'verifyInsertInto',
'UPDATE' => 'verifyUpdate',
'DELETE FROM' => 'verifyDeleteFrom',
)'
array(
'ALTER TABLE' => 'verifyAlterTable',
'DROP TABLE' => 'verifyDropTable',
'CREATE TABLE' => 'verifyCreateTable',
'INSERT INTO' => 'verifyInsertInto',
'UPDATE' => 'verifyUpdate',
'DELETE FROM' => 'verifyDeleteFrom',
)
Details- Type
- n/a
- Inherited_from
- \DBManager::$$standardQueries
- Inherited_from
- \MssqlManager::$$standardQueries
array
$table_descriptions= 'array()'
Table descriptions
Inherited from: \DBManager::$$table_descriptions\MssqlManager::$$table_descriptionsarray()
Details- Type
- array
- Inherited_from
- \DBManager::$$table_descriptions
- Inherited_from
- \MssqlManager::$$table_descriptions
\TimeDate
$timedate= ''
- Type
- \TimeDate
- Inherited_from
- \DBManager::$$timedate
- Inherited_from
- \MssqlManager::$$timedate
array
$type_class= 'array(
'int' => 'int',
'double' => 'float',
'float' => 'float',
'uint' => 'int',
'ulong' => 'bigint',
'long' => 'bigint',
'short' => 'int',
'date' => 'date',
'datetime' => 'date',
'datetimecombo' => 'date',
'time' => 'time',
'bool' => 'bool',
'tinyint' => 'int',
'currency' => 'float',
'decimal' => 'float',
'decimal2' => 'float',
)'
Type classification into: - int - bool - float - date
Inherited from: \DBManager::$$type_class\MssqlManager::$$type_classarray(
'int' => 'int',
'double' => 'float',
'float' => 'float',
'uint' => 'int',
'ulong' => 'bigint',
'long' => 'bigint',
'short' => 'int',
'date' => 'date',
'datetime' => 'date',
'datetimecombo' => 'date',
'time' => 'time',
'bool' => 'bool',
'tinyint' => 'int',
'currency' => 'float',
'decimal' => 'float',
'decimal2' => 'float',
)
Details- Type
- array
- Abstract
- Inherited_from
- \DBManager::$$type_class
- Inherited_from
- \MssqlManager::$$type_class
array
$type_map= 'array(
'int' => 'int',
'double' => 'float',
'float' => 'float',
'uint' => 'int',
'ulong' => 'int',
'long' => 'bigint',
'short' => 'smallint',
'varchar' => 'nvarchar',
'text' => 'nvarchar(max)',
'longtext' => 'nvarchar(max)',
'date' => 'datetime',
'enum' => 'nvarchar',
'relate' => 'nvarchar',
'multienum'=> 'nvarchar(max)',
'html' => 'nvarchar(max)',
'longhtml' => 'nvarchar(max)',
'datetime' => 'datetime',
'datetimecombo' => 'datetime',
'time' => 'datetime',
'bool' => 'bit',
'tinyint' => 'tinyint',
'char' => 'char',
'blob' => 'nvarchar(max)',
'longblob' => 'nvarchar(max)',
'currency' => 'decimal(26,6)',
'decimal' => 'decimal',
'decimal2' => 'decimal',
'id' => 'varchar(36)',
'url' => 'nvarchar',
'encrypt' => 'nvarchar',
'file' => 'nvarchar',
'decimal_tpl' => 'decimal(%d, %d)',
)'
Type names map
array(
'int' => 'int',
'double' => 'float',
'float' => 'float',
'uint' => 'int',
'ulong' => 'int',
'long' => 'bigint',
'short' => 'smallint',
'varchar' => 'nvarchar',
'text' => 'nvarchar(max)',
'longtext' => 'nvarchar(max)',
'date' => 'datetime',
'enum' => 'nvarchar',
'relate' => 'nvarchar',
'multienum'=> 'nvarchar(max)',
'html' => 'nvarchar(max)',
'longhtml' => 'nvarchar(max)',
'datetime' => 'datetime',
'datetimecombo' => 'datetime',
'time' => 'datetime',
'bool' => 'bit',
'tinyint' => 'tinyint',
'char' => 'char',
'blob' => 'nvarchar(max)',
'longblob' => 'nvarchar(max)',
'currency' => 'decimal(26,6)',
'decimal' => 'decimal',
'decimal2' => 'decimal',
'id' => 'varchar(36)',
'url' => 'nvarchar',
'encrypt' => 'nvarchar',
'file' => 'nvarchar',
'decimal_tpl' => 'decimal(%d, %d)',
)
Details- Type
- array
Methods
__get(
string $p
)
:
mixed
Wrapper for those trying to access the private and protected class members directly
Inherited from: \DBManager::__get()\MssqlManager::__get()Name | Type | Description |
---|---|---|
$p | string | var name |
Type | Description |
---|---|
mixed |
_appendN(
\$sql $sql
)
:
string
This is a utility function to prepend the "N" character in front of SQL values that are surrounded by single quotes.
Inherited from: \MssqlManager::_appendN()Name | Type | Description |
---|---|---|
$sql | \$sql | string SQL statement |
Type | Description |
---|---|
string | SQL statement with single quote values prepended with "N" character for nvarchar columns |
_emptyValue(
mixed $val, string $type
)
:
bool
Check if the value is empty value for this type
Inherited from: \DBManager::_emptyValue()\MssqlManager::_emptyValue()Name | Type | Description |
---|---|---|
$val | mixed | Value |
$type | string | Type (one of vardef types) |
Type | Description |
---|---|
bool | true if the value if empty |
_getBooleanValue(
mixed $val
)
:
bool
Get truth value for boolean type Allows 'off' to mean false, along with all 'empty' values
Inherited from: \DBManager::_getBooleanValue()\MssqlManager::_getBooleanValue()Name | Type | Description |
---|---|---|
$val | mixed |
Type | Description |
---|---|
bool |
addColumn(
string $tablename, array $fieldDefs
)
:
bool
Adds a column to table identified by field def.
Inherited from: \DBManager::addColumn()\MssqlManager::addColumn()Name | Type | Description |
---|---|---|
$tablename | string | |
$fieldDefs | array |
Type | Description |
---|---|
bool | query result |
addColumnSQL(
string $tablename, array $fieldDefs
)
:
string
This method generates sql for adding a column to table identified by field def.
Inherited from: \DBManager::addColumnSQL()\MssqlManager::addColumnSQL()Name | Type | Description |
---|---|---|
$tablename | string | |
$fieldDefs | array |
Type | Description |
---|---|
string | SQL statement |
addDistinctClause(
string $sql
)
:
void
addDistinctClause This method takes a SQL statement and checks if the disable_count_query setting is enabled before altering it. The alteration modifies the way the team security queries are made by changing it from a subselect to a distinct clause; hence the name of the method.
Inherited from: \DBManager::addDistinctClause()\MssqlManager::addDistinctClause()Name | Type | Description |
---|---|---|
$sql | string | value of SQL statement to alter |
addIndexes(
string $tablename, array $indexes, bool $execute
=
true
)
:
string
Name | Type | Description |
---|---|---|
$tablename | string | |
$indexes | array | indexes to add |
$execute | bool | true if we want to execute the returned sql statement |
Type | Description |
---|---|
string | SQL statement |
addPatternToSQL(
string $token, array $pattern_array
)
:
string
Name | Type | Description |
---|---|---|
$token | string | |
$pattern_array | array |
Type | Description |
---|---|
string |
add_drop_constraint(
string $table, array $definition, bool $drop
=
false
)
:
string
Generates alter constraint statement given a table name and vardef definition.
Inherited from: \MssqlManager::add_drop_constraint()Supports both adding and droping a constraint.
Name | Type | Description |
---|---|---|
$table | string | tablename |
$definition | array | field definition |
$drop | bool | true if we are dropping the constraint, false if we are adding it |
Type | Description |
---|---|
string | SQL statement |
alterColumn(
string $tablename, array $newFieldDef, bool $ignoreRequired
=
false
)
:
bool
Alters old column identified by oldFieldDef to new fieldDef.
Inherited from: \DBManager::alterColumn()\MssqlManager::alterColumn()Name | Type | Description |
---|---|---|
$tablename | string | |
$newFieldDef | array | |
$ignoreRequired | bool | optional, true if we are ignoring this being a required field |
Type | Description |
---|---|
bool | query result |
alterColumnSQL(
string $tablename, array $newFieldDefs, bool $ignorerequired
=
false
)
:
string | array
This method genrates sql for altering old column identified by oldFieldDef to new fieldDef.
Inherited from: \DBManager::alterColumnSQL()\MssqlManager::alterColumnSQL()Name | Type | Description |
---|---|---|
$tablename | string | |
$newFieldDefs | array | |
$ignorerequired | bool | Optional, true if we should ignor this being a required field |
Type | Description |
---|---|
string | array | SQL statement(s) |
alterSQLRep(
string $action, array $def, $ignoreRequired, string $tablename
)
:
void
MSSQL has a quirky T-SQL alter table syntax. Pay special attention to the modify operation
Name | Type | Description |
---|---|---|
$action | string | |
$def | array | |
$ignoreRequired | ||
$tablename | string |
arrayQuote(
array $array
)
:
array
Quote the strings of the passed in array
Inherited from: \DBManager::arrayQuote()\MssqlManager::arrayQuote()The array must only contain strings
Name | Type | Description |
---|---|---|
$array | array |
Type | Description |
---|---|
array | Quoted strings |
auditSQL(
\SugarBean $bean, array $changes
)
:
string
Generate query for audit table
Inherited from: \DBManager::auditSQL()\MssqlManager::auditSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean that was changed |
$changes | array | List of changes, contains 'before' and 'after' |
Type | Description |
---|---|
string | Audit table INSERT query |
canInstall(
)
:
mixed
Check special requirements for DB installation.
Inherited from: \DBManager::canInstall()\MssqlManager::canInstall()Type | Description |
---|---|
mixed |
- Abstract
- If everything is OK, return true. If something's wrong, return array of error code and parameters
changeColumnSQL(
string $tablename, array $fieldDefs, string $action, bool $ignoreRequired
=
false
)
:
string | array
Override method to add support for detecting and dropping fulltext indices.
Name | Type | Description |
---|---|---|
$tablename | string | |
$fieldDefs | array | |
$action | string | |
$ignoreRequired | bool | Optional, true if we should ignor this being a required field |
Type | Description |
---|---|
string | array |
- See
- \DBManager::changeColumnSQL()
- See
- \MssqlHelper::changeColumnSQL()
checkConnection(
)
:
void
Checks the current connection; if it is not connected then reconnect
Inherited from: \DBManager::checkConnection()\MssqlManager::checkConnection()checkError(
string $msg
=
'', bool $dieOnError
=
false
)
:
bool
Checks for error happening in the database
Inherited from: \DBManager::checkError()\MssqlManager::checkError()Name | Type | Description |
---|---|---|
$msg | string | message to prepend to the error message |
$dieOnError | bool | true if we want to die immediately on error |
Type | Description |
---|---|
bool | True if there was an error |
checkPrivilege(
string $privilege
)
:
bool
Check if connecting user has certain privilege
Inherited from: \DBManager::checkPrivilege()\MssqlManager::checkPrivilege()Name | Type | Description |
---|---|---|
$privilege | string |
Type | Description |
---|---|
bool | Privilege allowed? |
checkQuery(
string $sql, bool $object_name
=
false
)
:
bool
Scans order by to ensure that any field being ordered by is.
Inherited from: \DBManager::checkQuery()\MssqlManager::checkQuery()It will throw a warning error to the log file - fatal if slow query logging is enabled
Name | Type | Description |
---|---|---|
$sql | string | query to be run |
$object_name | bool | optional, object to look up indices in |
Type | Description |
---|---|
bool | true if an index is found false otherwise |
columnSQLRep(
array $fieldDefs, bool $ignoreRequired
=
false, string $tablename
)
:
string
Returns SQL defintions for all columns in a table
Inherited from: \DBManager::columnSQLRep()\MssqlManager::columnSQLRep()Name | Type | Description |
---|---|---|
$fieldDefs | array | Vardef-format field def |
$ignoreRequired | bool | Optional, true if we should ignor this being a required field |
$tablename | string | Optional, table name |
Type | Description |
---|---|
string | SQL column definitions |
commit(
)
:
bool
Commits pending changes to the database when the driver is setup to support transactions.
Inherited from: \DBManager::commit()\MssqlManager::commit()Note that the default implementation is applicable for transaction-less or auto commit scenarios.
Type | Description |
---|---|
bool | true if commit succeeded, false if it failed |
- Abstract
compareFieldInTables(
string $name, string $table1, string $table2
)
:
array
Compare a field in two tables
Inherited from: \DBManager::compareFieldInTables()\MssqlManager::compareFieldInTables()Name | Type | Description |
---|---|---|
$name | string | field name |
$table1 | string | |
$table2 | string |
Type | Description |
---|---|
array | array with keys 'msg','table1','table2' |
compareVarDefs(
array $fielddef1, array $fielddef2
)
:
bool
Compares two vardefs. Overriding 39098 due to bug: 39098 . IN 6.0 we changed the id columns to dbType = 'id' for example emails_beans. In 554 the field email_id was nvarchar but in 6.0 since it id dbType = 'id' we would want to alter it to varchar. This code will prevent it.
Name | Type | Description |
---|---|---|
$fielddef1 | array | |
$fielddef2 | array |
Type | Description |
---|---|
bool | true if they match, false if they don't |
concat(
string $table, array $fields, string $space
=
' '
)
:
string
Returns the database string needed for concatinating multiple database strings together
Inherited from: \DBManager::concat()\MssqlManager::concat()Name | Type | Description |
---|---|---|
$table | string | table name of the database fields to concat |
$fields | array | fields in the table to concat together |
$space | string | Separator between strings, default is single space |
Type | Description |
---|---|
string |
connect(
array $configOptions
=
null, boolean $dieOnError
=
false
)
:
void
Connects to the database backend
Takes in the database settings and opens a database connection based on those will open either a persistent or non-persistent connection. If a persistent connection is desired but not available it will defualt to non-persistent
configOptions must include db_host_name - server ip db_user_name - database user name db_password - database password
Name | Type | Description |
---|---|---|
$configOptions | array | |
$dieOnError | boolean |
convert(
string $string, string $type, array $additional_parameters
=
array()
)
:
string
Use when you need to convert a database string to a different value; this function does it in a database-backend aware way Supported conversions: today return current date left Take substring from the left date_format Format date as string, supports %Y-%m-%d, %Y-%m, %Y time_format Format time as string date Convert date string to datetime value time Convert time string to datetime value datetime Convert datetime string to datetime value ifnull If var is null, use default value concat Concatenate strings quarter Quarter number of the date length Length of string month Month number of the date add_date Add specified interval to a date add_time Add time interval to a date text2char Convert text field to varchar
Name | Type | Description |
---|---|---|
$string | string | database string to convert |
$type | string | type of conversion to do |
$additional_parameters | array | optional, additional parameters to pass to the db function |
Type | Description |
---|---|
string |
countQuery(
)
:
void
This function increments the global $sql_queries variable
Inherited from: \DBManager::countQuery()\MssqlManager::countQuery()createConstraintSql(
\SugarBean $bean
)
:
array
returns SQL to create constraints or indices
Inherited from: \DBManager::createConstraintSql()\MssqlManager::createConstraintSql()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
Type | Description |
---|---|
array | list of SQL statements |
createDbUser(
string $database_name, string $host_name, string $user, string $password
)
:
void
Name | Type | Description |
---|---|---|
$database_name | string | |
$host_name | string | |
$user | string | |
$password | string |
createIndex(
\SugarBean $bean, array $fieldDefs, string $name, bool $unique
=
true
)
:
bool
Creates an index identified by name on the given fields.
Inherited from: \DBManager::createIndex()\MssqlManager::createIndex()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$fieldDefs | array | Field definitions, in vardef format |
$name | string | index name |
$unique | bool | optional, true if we want to create an unique index |
Type | Description |
---|---|
bool | query result |
createIndexSQL(
\SugarBean $bean, array $fields, string $name, bool $unique
=
true
)
:
string
Generates SQL for create index statement for a bean.
Inherited from: \DBManager::createIndexSQL()\MssqlManager::createIndexSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$fields | array | fields used in the index |
$name | string | index name |
$unique | bool | Optional, set to true if this is an unique index |
Type | Description |
---|---|
string | SQL Select Statement |
createTable(
\SugarBean $bean
)
:
void
Implements creation of a db table for a bean.
Inherited from: \DBManager::createTable()\MssqlManager::createTable()NOTE: does not handle out-of-table constraints, use createConstraintSQL for that
Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance |
createTableParams(
string $tablename, array $fieldDefs, array $indices, string $engine
=
null
)
:
bool
Implements creation of a db table
Inherited from: \DBManager::createTableParams()\MssqlManager::createTableParams()Name | Type | Description |
---|---|---|
$tablename | string | |
$fieldDefs | array | Field definitions, in vardef format |
$indices | array | Index definitions, in vardef format |
$engine | string | Engine parameter, used for MySQL engine so far |
Type | Description |
---|---|
bool | success value |
createTableSQL(
\SugarBean $bean
)
:
string
Generates sql for create table statement for a bean.
Inherited from: \DBManager::createTableSQL()\MssqlManager::createTableSQL()NOTE: does not handle out-of-table constraints, use createConstraintSQL for that
Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
Type | Description |
---|---|
string | SQL Create Table statement |
createTableSQLParams(
string $tablename, array $fieldDefs, array $indices
)
:
string
Generates sql for create table statement for a bean.
Inherited from: \MssqlManager::createTableSQLParams()Name | Type | Description |
---|---|---|
$tablename | string | |
$fieldDefs | array | |
$indices | array |
Type | Description |
---|---|
string | SQL Create Table statement |
create_default_full_text_catalog(
)
:
void
Creates default full text catalog
Inherited from: \MssqlManager::create_default_full_text_catalog()delete(
\SugarBean $bean, array $where
=
array()
)
:
bool
Implements a generic delete for any bean identified by id
Inherited from: \DBManager::delete()\MssqlManager::delete()Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance |
$where | array | values with the keys as names of fields. If we want to pass multiple values for a name, pass it as an array If where is not passed, it defaults to id of table |
Type | Description |
---|---|
bool | query result |
deleteAutoIncrement(
string $table, string $field_name
)
:
void
Deletes an auto increment
Inherited from: \DBManager::deleteAutoIncrement()\MssqlManager::deleteAutoIncrement()Name | Type | Description |
---|---|---|
$table | string | tablename |
$field_name | string |
- Abstract
deleteColumn(
\SugarBean $bean, array $fieldDefs
)
:
bool
Deletes a column identified by fieldDef.
Inherited from: \DBManager::deleteColumn()\MssqlManager::deleteColumn()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean containing the field |
$fieldDefs | array | Vardef definition of the field |
Type | Description |
---|---|
bool | query result |
deleteColumnSQL(
\SugarBean $bean, array $fieldDefs
)
:
string
This method generates sql that deletes a column identified by fieldDef.
Inherited from: \DBManager::deleteColumnSQL()\MssqlManager::deleteColumnSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance |
$fieldDefs | array |
Type | Description |
---|---|
string | SQL statement |
deleteSQL(
\SugarBean $bean, array $where
)
:
string
Generates SQL for delete statement identified by id.
Inherited from: \DBManager::deleteSQL()\MssqlManager::deleteSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$where | array | where conditions in an array |
Type | Description |
---|---|
string | SQL Update Statement |
describeField(
string $name, string $tablename
)
:
array
Returns the field description for a given field in table
Inherited from: \DBManager::describeField()\MssqlManager::describeField()Name | Type | Description |
---|---|---|
$name | string | |
$tablename | string |
Type | Description |
---|---|
array |
describeIndex(
string $name, string $tablename
)
:
array
Returns the index description for a given index in table
Inherited from: \DBManager::describeIndex()\MssqlManager::describeIndex()Name | Type | Description |
---|---|---|
$name | string | |
$tablename | string |
Type | Description |
---|---|
array |
disableKeys(
string $tableName
)
:
void
Disable keys on the table
Inherited from: \DBManager::disableKeys()\MssqlManager::disableKeys()Name | Type | Description |
---|---|---|
$tableName | string |
- Abstract
doesTableHaveAClusteredIndexDefined(
string $tableName
)
:
bool
protected function to return true if the given tablename has any clustered indexes defined.
Name | Type | Description |
---|---|---|
$tableName | string |
Type | Description |
---|---|
bool |
doesTableHaveAFulltextIndexDefined(
string $tableName
)
:
bool
protected function to return true if the given tablename has any fulltext indexes defined.
Name | Type | Description |
---|---|---|
$tableName | string |
Type | Description |
---|---|
bool |
dropColumnSQL(
string $tablename, array $fieldDefs
)
:
string
This method generates sql that drops a column identified by fieldDef.
Inherited from: \DBManager::dropColumnSQL()\MssqlManager::dropColumnSQL()Designed to work like the other addColumnSQL() and alterColumnSQL() functions
Name | Type | Description |
---|---|---|
$tablename | string | |
$fieldDefs | array |
Type | Description |
---|---|
string | SQL statement |
dropIndexes(
string $tablename, array $indexes, bool $execute
=
true
)
:
string
Name | Type | Description |
---|---|---|
$tablename | string | |
$indexes | array | indexes to drop |
$execute | bool | true if we want to execute the returned sql statement |
Type | Description |
---|---|
string | SQL statement |
dropTable(
\SugarBean $bean
)
:
bool
Drops the table associated with a bean
Inherited from: \DBManager::dropTable()\MssqlManager::dropTable()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
Type | Description |
---|---|
bool | query result |
dropTableName(
string $name
)
:
bool
Drops the table by name
Inherited from: \DBManager::dropTableName()\MssqlManager::dropTableName()Name | Type | Description |
---|---|---|
$name | string | Table name |
Type | Description |
---|---|
bool | query result |
dropTableNameSQL(
string $name
)
:
string
Generates SQL for dropping a table.
Inherited from: \DBManager::dropTableNameSQL()\MssqlManager::dropTableNameSQL()Name | Type | Description |
---|---|---|
$name | string | table name |
Type | Description |
---|---|
string | SQL statement |
dropTableSQL(
\SugarBean $bean
)
:
string
Generates SQL for dropping a table.
Inherited from: \DBManager::dropTableSQL()\MssqlManager::dropTableSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance |
Type | Description |
---|---|
string | SQL statement |
dump_slow_queries(
string $query
)
:
boolean
This method is called by every method that runs a query.
Inherited from: \DBManager::dump_slow_queries()\MssqlManager::dump_slow_queries()If slow query dumping is turned on and the query time is beyond the time limit, we will log the query. This function may do additional reporting or log in a different area in the future.
Name | Type | Description |
---|---|---|
$query | string | query to log |
Type | Description |
---|---|
boolean | true if the query was logged, false otherwise |
emptyValue(
string $type
)
:
mixed
Return representation of an empty value depending on type
Inherited from: \MssqlManager::emptyValue()Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
mixed | Empty value |
enableKeys(
string $tableName
)
:
void
Re-enable keys on the table
Inherited from: \DBManager::enableKeys()\MssqlManager::enableKeys()Name | Type | Description |
---|---|---|
$tableName | string |
- Abstract
escape_quote(
string $string
)
:
string
Quotes a string for storing in the database
Inherited from: \DBManager::escape_quote()\MssqlManager::escape_quote()Name | Type | Description |
---|---|---|
$string | string |
Type | Description |
---|---|
string |
executePreparedQuery(
int $stmt, array $data
=
array()
)
:
resource
Takes a prepared stmt index and the data to replace and creates the query and runs it.
Inherited from: \DBManager::executePreparedQuery()\MssqlManager::executePreparedQuery()Name | Type | Description |
---|---|---|
$stmt | int | The index of the prepared statement from preparedTokens |
$data | array | The array of data to replace the tokens with. |
Type | Description |
---|---|
resource | result set or false on error |
extractTableName(
string $query
)
:
string
Extract table name from a query
Inherited from: \DBManager::extractTableName()\MssqlManager::extractTableName()Name | Type | Description |
---|---|---|
$query | string | SQL query |
Type | Description |
---|---|
string |
fetchByAssoc(
resource $result, bool $encode
=
true
)
:
array
Fetches the next row in the query result into an associative array
Inherited from: \DBManager::fetchByAssoc()\MssqlManager::fetchByAssoc()Name | Type | Description |
---|---|---|
$result | resource | |
$encode | bool | Need to HTML-encode the result? |
Type | Description |
---|---|
array | returns false if there are no more rows available to fetch |
fetchOne(
string $sql, bool $dieOnError
=
false, string $msg
=
'', bool $suppress
=
false
)
:
array
Runs a query and returns a single row
Inherited from: \DBManager::fetchOne()\MssqlManager::fetchOne()Name | Type | Description |
---|---|---|
$sql | string | SQL Statement to execute |
$dieOnError | bool | True if we want to call die if the query returns errors |
$msg | string | Message to log if error occurs |
$suppress | bool | Message to log if error occurs |
Type | Description |
---|---|
array | single row from the query |
fetchRow(
resource $result
)
:
array
Fetches the next row in the query result into an associative array
Name | Type | Description |
---|---|---|
$result | resource |
Type | Description |
---|---|
array | returns false if there are no more rows available to fetch |
findColumnByAlias(
string $sql, string $orderMatch
)
:
string
Finds the alias of the order by column, and then return the preceding column name
Inherited from: \MssqlManager::findColumnByAlias()Name | Type | Description |
---|---|---|
$sql | string | |
$orderMatch | string |
Type | Description |
---|---|
string |
freeDbResult(
resource $dbResult
)
:
void
Free Database result
Name | Type | Description |
---|---|---|
$dbResult | resource |
freeResult(
resource | bool $result
=
false
)
:
void
Frees out previous results
Inherited from: \DBManager::freeResult()\MssqlManager::freeResult()Name | Type | Description |
---|---|---|
$result | resource | bool | optional, pass if you want to free a single result instead of all results |
fromConvert(
string $string, string $type
)
:
string
Supported types - date - time - datetime - datetimecombo - timestamp
Name | Type | Description |
---|---|---|
$string | string | database string to convert |
$type | string | type of conversion to do |
Type | Description |
---|---|
string |
full_text_indexing_enabled(
$dbname
=
null
)
:
void
Name | Type | Description |
---|---|---|
$dbname |
full_text_indexing_installed(
)
:
bool
Returns true if Full Text Search is installed
Inherited from: \MssqlManager::full_text_indexing_installed()Type | Description |
---|---|
bool |
full_text_indexing_setup(
)
:
void
This call is meant to be used during install, when Full Text Search is enabled Indexing would always occur after a fresh sql server install, so this code creates a catalog and table with full text index.
Inherited from: \MssqlManager::full_text_indexing_setup()generateInsertSQL(
\SugarBean $bean, string $select_query, int $start, int $count
=
-1, string $table, bool $is_related_query
=
false
)
:
string
Generate a set of Insert statements based on the bean given
Inherited from: \DBManager::generateInsertSQL()\MssqlManager::generateInsertSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | the bean from which table we will generate insert stmts |
$select_query | string | the query which will give us the set of objects we want to place into our insert statement |
$start | int | the first row to query |
$count | int | the number of rows to query |
$table | string | the table to query from |
$is_related_query | bool |
Type | Description |
---|---|
string | SQL insert statement |
getAffectedRowCount(
)
:
int
Returns the number of rows affected by the last query
Inherited from: \MssqlManager::getAffectedRowCount()Type | Description |
---|---|
int |
getAliasFromSQL(
string $sql, string $alias
)
:
string
Name | Type | Description |
---|---|---|
$sql | string | |
$alias | string |
Type | Description |
---|---|
string |
getAutoIncrement(
string $table, string $field_name
)
:
string
Returns the next value for an auto increment
Inherited from: \MssqlManager::getAutoIncrement()Name | Type | Description |
---|---|---|
$table | string | Table name |
$field_name | string | Field name |
Type | Description |
---|---|
string |
getAutoIncrementSQL(
string $table, string $field_name
)
:
string
Returns the sql for the next value in a sequence
Inherited from: \DBManager::getAutoIncrementSQL()\MssqlManager::getAutoIncrementSQL()Name | Type | Description |
---|---|---|
$table | string | Table name |
$field_name | string | Field name |
Type | Description |
---|---|
string |
- Abstract
getCollationList(
)
:
array
List of available collation settings
Inherited from: \DBManager::getCollationList()\MssqlManager::getCollationList()Type | Description |
---|---|
array |
- Abstract
getColumnType(
string $type
)
:
string
Returns the valid type for a column given the type in fieldDef
Inherited from: \DBManager::getColumnType()\MssqlManager::getColumnType()Name | Type | Description |
---|---|---|
$type | string | field type |
Type | Description |
---|---|
string | valid type for the given field |
getColumnWhereClause(
string $table, array $whereArray
=
array()
)
:
string
Returns a where clause without the 'where' key word
Inherited from: \DBManager::getColumnWhereClause()\MssqlManager::getColumnWhereClause()The clause returned does not have an 'and' at the beginning and the columns are joined by 'and'.
Name | Type | Description |
---|---|---|
$table | string | table name |
$whereArray | array | Optional, where conditions in an array |
Type | Description |
---|---|
string |
getConstraintSql(
array $indices, string $table
)
:
array
Detect if no clustered index has been created for a table; if none created then just pick the first index and make it that
Name | Type | Description |
---|---|---|
$indices | array | Assoc array with index definitions from vardefs |
$table | string | Focus table |
Type | Description |
---|---|
array | Array of SQL queries to generate indices |
- See
- \MssqlHelper::indexSQL()
getDataChanges(
\SugarBean $bean
)
:
array
Uses the audit enabled fields array to find fields whose value has changed.
Inherited from: \DBManager::getDataChanges()\MssqlManager::getDataChanges()The before and after values are stored in the bean. Uses $bean->fetched_row to compare
Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance that was changed |
Type | Description |
---|---|
array |
getDatabase(
)
:
resource
Returns the current database handle
Inherited from: \DBManager::getDatabase()\MssqlManager::getDatabase()Type | Description |
---|---|
resource |
getDefaultCollation(
)
:
string
List of available collation settings
Inherited from: \DBManager::getDefaultCollation()\MssqlManager::getDefaultCollation()Type | Description |
---|---|
string |
- Abstract
getFieldNameFromSelect(
string $string
)
:
string
returns the field name used in a select
Inherited from: \DBManager::getFieldNameFromSelect()\MssqlManager::getFieldNameFromSelect()Name | Type | Description |
---|---|---|
$string | string | SELECT query |
Type | Description |
---|---|
string |
getFieldType(
array $fieldDef
)
:
string
Returns the type of the variable in the field
Inherited from: \DBManager::getFieldType()\MssqlManager::getFieldType()Name | Type | Description |
---|---|---|
$fieldDef | array | Vardef-format field def |
Type | Description |
---|---|
string |
getFieldsArray(
resource $result, boolean $make_lower_case
=
false
)
:
array
Returns the description of fields based on the result
Name | Type | Description |
---|---|---|
$result | resource | |
$make_lower_case | boolean |
Type | Description |
---|---|
array | field array |
getFromDummyTable(
)
:
string
Returns a DB specific FROM clause which can be used to select against functions.
Inherited from: \MssqlManager::getFromDummyTable()Note that depending on the database that this may also be an empty string.
Type | Description |
---|---|
string |
getFulltextQuery(
$field, array $terms, array $must_terms
=
array(), array $exclude_terms
=
array()
)
:
void
Generate fulltext query from set of terms
Inherited from: \MssqlManager::getFulltextQuery()Name | Type | Description |
---|---|---|
$field | ||
$terms | array | Search terms that may be or not be in the result |
$must_terms | array | Search terms that have to be in the result |
$exclude_terms | array | Search terms that have to be not in the result |
getGuidSQL(
)
:
string
Returns a DB specific piece of SQL which will generate GUID (UUID) This string can be used in dynamic SQL to do multiple inserts with a single query.
Inherited from: \MssqlManager::getGuidSQL()I.e. generate a unique Sugar id in a sub select of an insert statement.
Type | Description |
---|---|
string |
getHelper(
)
:
\DBManager
Returns this instance's DBHelper Actually now returns $this
Inherited from: \DBManager::getHelper()\MssqlManager::getHelper()Type | Description |
---|---|
\DBManager |
getOne(
string $sql, bool $dieOnError
=
false, string $msg
=
''
)
:
array
Runs a query and returns a single row containing single value
Inherited from: \DBManager::getOne()\MssqlManager::getOne()Name | Type | Description |
---|---|---|
$sql | string | SQL Statement to execute |
$dieOnError | bool | True if we want to call die if the query returns errors |
$msg | string | Message to log if error occurs |
Type | Description |
---|---|
array | single value from the query |
getOption(
string $option
)
:
mixed
Name | Type | Description |
---|---|---|
$option | string | Option name |
Type | Description |
---|---|
mixed | Option value or null if doesn't exist |
getQueryCount(
)
:
int
Returns the static queryCount value
Inherited from: \DBManager::getQueryCount()\MssqlManager::getQueryCount()Type | Description |
---|---|
int | value of the queryCount static variable |
getQueryTime(
)
:
int
Returns the time the last query took to execute
Inherited from: \DBManager::getQueryTime()\MssqlManager::getQueryTime()Type | Description |
---|---|
int |
getRowCount(
resource $result
)
:
int
Returns the number of rows returned by the result
Inherited from: \DBManager::getRowCount()\MssqlManager::getRowCount()This function can't be reliably implemented on most DB, do not use it.
Name | Type | Description |
---|---|---|
$result | resource |
Type | Description |
---|---|
int |
- Abstract
getScriptName(
)
:
string
Get DB driver name used for install/upgrade scripts
Inherited from: \DBManager::getScriptName()\MssqlManager::getScriptName()Type | Description |
---|---|
string |
getSelectFieldsFromQuery(
string $selectStatement
)
:
array
Take an SQL statement and produce a list of fields used in that select
Inherited from: \DBManager::getSelectFieldsFromQuery()\MssqlManager::getSelectFieldsFromQuery()Name | Type | Description |
---|---|---|
$selectStatement | string |
Type | Description |
---|---|
array |
getTableDescription(
string $tablename, bool $reload
=
false
)
:
array
Get table description
Inherited from: \DBManager::getTableDescription()\MssqlManager::getTableDescription()Name | Type | Description |
---|---|---|
$tablename | string | |
$reload | bool | true means load from DB, false allows using cache |
Type | Description |
---|---|
array | Vardef-format table description |
getTableNameFromModuleName(
string $module_str, string $sql
)
:
string
Take in a string of the module and retrieve the correspondent table name
Inherited from: \MssqlManager::getTableNameFromModuleName()Name | Type | Description |
---|---|---|
$module_str | string | module name |
$sql | string | SQL statement |
Type | Description |
---|---|
string | table name |
getTablesArray(
)
:
array | false
Returns an array of tables for this database
Inherited from: \MssqlManager::getTablesArray()Type | Description |
---|---|
array | false | an array of with table names, false if no tables found |
getTypeParts(
string $type
)
:
array | bool
retrieves the different components from the passed column type as it is used in the type mapping and vardefs
type format:
Name | Type | Description |
---|---|---|
$type | string | Column type |
Type | Description |
---|---|
array | bool | array containing the different components of the passed in type or false in case the type contains illegal characters |
getValidDBName(
string | array $name, bool | string $ensureUnique
=
false, string $type
=
'column', bool $force
=
false
)
:
string | array
Return a version of $proposed that can be used as a column name in any of our supported databases Practically this means no longer than 25 characters as the smallest identifier length for our supported DBs is 30 chars for Oracle plus we add on at least four characters in some places (for indicies for example)
Inherited from: \DBManager::getValidDBName()\MssqlManager::getValidDBName()Name | Type | Description |
---|---|---|
$name | string | array | Proposed name for the column |
$ensureUnique | bool | string | Ensure the name is unique |
$type | string | Name type (table, column) |
$force | bool | Force new name |
Type | Description |
---|---|
string | array | Valid column name trimmed to right length and with invalid characters removed |
getWhereClause(
\SugarBean $bean, array $whereArray
=
array()
)
:
string
This method returns a complete where clause built from the where values specified.
Inherited from: \DBManager::getWhereClause()\MssqlManager::getWhereClause()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean that describes the table |
$whereArray | array | Optional, where conditions in an array |
Type | Description |
---|---|
string |
get_columns(
string $tablename
)
:
array
Returns definitions of all indies for passed table.
return will is a multi-dimensional array that categorizes the index definition by types, unique, primary and index.
array (
'name' => 'field1',
'type' => 'varchar',
'len' => '200'
)
)
?>
This format is similar to how indicies are defined in vardef file.
Name | Type | Description |
---|---|---|
$tablename | string |
Type | Description |
---|---|
array |
get_field_default_constraint_name(
string $table, string $column
=
null
)
:
string
Function returns name of the constraint automatically generated by sql-server.
Inherited from: \MssqlManager::get_field_default_constraint_name()We request this for default, primary key, required
Name | Type | Description |
---|---|---|
$table | string | |
$column | string |
Type | Description |
---|---|
string |
get_indices(
$tableName
)
:
array
Returns definitions of all indies for passed table.
Inherited from: \MssqlManager::get_indices()return will is a multi-dimensional array that categorizes the index definition by types, unique, primary and index.
array (
'name' => 'index1',
'type' => 'primary',
'fields' => array('field1','field2')
)
)
?>
This format is similar to how indicies are defined in vardef file.
Name | Type | Description |
---|---|---|
$tableName |
Type | Description |
---|---|
array |
handleUnionLimitQuery(
string $sql, int $start, int $count
)
:
string
This function take in the sql for a union query, the start and offset, and wraps it around an "mssql friendly" limit query
Inherited from: \MssqlManager::handleUnionLimitQuery()Name | Type | Description |
---|---|---|
$sql | string | |
$start | int | record to start at |
$count | int | number of records to retrieve |
Type | Description |
---|---|
string | SQL statement |
hasLimit(
string $sql
)
:
bool
Name | Type | Description |
---|---|---|
$sql | string |
Type | Description |
---|---|
bool |
- Abstract
- Check if query has LIMIT clause Relevant for now only for Mysql
insert(
\SugarBean $bean
)
:
bool
Implements a generic insert for any bean.
Inherited from: \DBManager::insert()\MssqlManager::insert()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
Type | Description |
---|---|
bool | query result |
insertParams(
string $table, array $field_defs, array $data, array $field_map
=
null, bool $execute
=
true
)
:
bool
Insert data into table by parameter definition
Inherited from: \DBManager::insertParams()\MssqlManager::insertParams()Name | Type | Description |
---|---|---|
$table | string | Table name |
$field_defs | array | Definitions in vardef-like format |
$data | array | Key/value to insert |
$field_map | array | Fields map from SugarBean |
$execute | bool | Execute or return query? |
Type | Description |
---|---|
bool | query result |
insertSQL(
\SugarBean $bean
)
:
string
Generates SQL for insert statement.
Inherited from: \DBManager::insertSQL()\MssqlManager::insertSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
Type | Description |
---|---|
string | SQL Create Table statement |
isBooleanType(
string $type
)
:
bool
Check if type is boolean
Inherited from: \DBManager::isBooleanType()\MssqlManager::isBooleanType()Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
bool |
isDatabaseNameValid(
string $name
)
:
bool
Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
bool |
isFieldArray(
mixed $defArray
)
:
bool
Checks to see if passed array is truely an array of defitions
Inherited from: \DBManager::isFieldArray()\MssqlManager::isFieldArray()Such an array may have type as a key but it will point to an array for a true array of definitions an to a col type for a definition only
Name | Type | Description |
---|---|---|
$defArray | mixed |
Type | Description |
---|---|
bool |
isNullable(
array $vardef
)
:
bool
Can this field be null? Auto-increment and ID fields can not be null
Inherited from: \DBManager::isNullable()\MssqlManager::isNullable()Name | Type | Description |
---|---|---|
$vardef | array |
Type | Description |
---|---|
bool |
isNumericType(
string $type
)
:
bool
Check if type is a number
Inherited from: \DBManager::isNumericType()\MssqlManager::isNumericType()Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
bool |
isSelect(
string $query
)
:
bool
Check if the query is a select query
Inherited from: \DBManager::isSelect()\MssqlManager::isSelect()Name | Type | Description |
---|---|---|
$query | string |
Type | Description |
---|---|
bool | Is query SELECT? |
isTextType(
string $type
)
:
bool
Does this type represent text (i.e., non-varchar) value?
Inherited from: \MssqlManager::isTextType()Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
bool |
lastDbError(
)
:
string | false
(non-PHPdoc)
Type | Description |
---|---|
string | false | Error message or false if no error happened |
lastError(
)
:
string
Return DB error message for the last query executed
Inherited from: \DBManager::lastError()\MssqlManager::lastError()Type | Description |
---|---|
string | Last error message |
limitQuery(
string $sql, int $start, int $count, boolean $dieOnError
=
false, string $msg
=
'', bool $execute
=
true
)
:
resource
FIXME: verify and thoroughly test this code, these regexps look fishy
Inherited from: \MssqlManager::limitQuery()Name | Type | Description |
---|---|---|
$sql | string | SELECT query |
$start | int | Starting row |
$count | int | How many rows |
$dieOnError | boolean | True if we want to call die if the query returns errors |
$msg | string | Message to log if error occurs |
$execute | bool | Execute or return SQL? |
Type | Description |
---|---|
resource | query result |
limitQuerySql(
string $sql, int $start, int $count, bool $dieOnError
=
false, string $msg
=
''
)
:
resource | bool
Return limit query based on given query
Inherited from: \DBManager::limitQuerySql()\MssqlManager::limitQuerySql()Name | Type | Description |
---|---|---|
$sql | string | |
$start | int | |
$count | int | |
$dieOnError | bool | |
$msg | string |
Type | Description |
---|---|
resource | bool | query result |
massageFieldDef(
array $fieldDef, string $tablename
)
:
array
Massages the field defintions to fill in anything else the DB backend may add
Inherited from: \MssqlManager::massageFieldDef()Name | Type | Description |
---|---|---|
$fieldDef | array | |
$tablename | string |
Type | Description |
---|---|
array |
massageValue(
mixed $val, array $fieldDef
)
:
mixed
Outputs a correct string for the sql statement according to value
Inherited from: \DBManager::massageValue()\MssqlManager::massageValue()Name | Type | Description |
---|---|---|
$val | mixed | |
$fieldDef | array | field definition |
Type | Description |
---|---|
mixed |
modifyIndexes(
string $tablename, array $indexes, bool $execute
=
true
)
:
string
Name | Type | Description |
---|---|---|
$tablename | string | |
$indexes | array | indexes to modify |
$execute | bool | true if we want to execute the returned sql statement |
Type | Description |
---|---|
string | SQL statement |
now(
)
:
string
Return current time in format fit for insertion into DB (with quotes)
Inherited from: \DBManager::now()\MssqlManager::now()Type | Description |
---|---|
string |
number_of_columns(
string $table_name
)
:
int
Returns the number of columns in a table
Inherited from: \DBManager::number_of_columns()\MssqlManager::number_of_columns()Name | Type | Description |
---|---|---|
$table_name | string |
Type | Description |
---|---|
int |
oneColumnSQLRep(
array $fieldDef, bool $ignoreRequired
=
false, string $table
=
'', bool $return_as_array
=
false
)
:
string
Name | Type | Description |
---|---|---|
$fieldDef | array | Vardef-format field def |
$ignoreRequired | bool | Optional, true if we should ignore this being a required field |
$table | string | Optional, table name |
$return_as_array | bool | Optional, true if we should return the result as an array instead of sql |
Type | Description |
---|---|
string | or array if $return_as_array is true |
orderByEnum(
string $order_by, array $values, string $order_dir
)
:
string
Create ORDER BY clause for ENUM type field
Inherited from: \DBManager::orderByEnum()\MssqlManager::orderByEnum()Name | Type | Description |
---|---|---|
$order_by | string | Field name |
$values | array | Possible enum value |
$order_dir | string | Order direction, ASC or DESC |
Type | Description |
---|---|
string |
pQuery(
string $sql, array $data
=
array()
)
:
resource
Run both prepare and execute without the client having to run both individually.
Inherited from: \DBManager::pQuery()\MssqlManager::pQuery()Name | Type | Description |
---|---|---|
$sql | string | The sql to parse |
$data | array | The array of data to replace the tokens with. |
Type | Description |
---|---|
resource | result set or false on error |
parseFulltextQuery(
string $query
)
:
array
Parse fulltext search query with mysql syntax: terms quoted by "" + means the term must be included - means the term must be excluded * or % at the end means wildcard
Inherited from: \DBManager::parseFulltextQuery()\MssqlManager::parseFulltextQuery()Name | Type | Description |
---|---|---|
$query | string |
Type | Description |
---|---|
array | of 3 elements - query terms, mandatory terms and excluded terms |
prepareQuery(
string $sql
)
:
int
Given a sql stmt attempt to parse it into the sql and the tokens. Then return the index of this prepared statement Tokens can come in the following forms: ? - a scalar which will be quoted ! - a literal which will not be quoted & - binary data to read from a file
Inherited from: \DBManager::prepareQuery()\MssqlManager::prepareQuery()Name | Type | Description |
---|---|---|
$sql | string | The sql to parse |
Type | Description |
---|---|
int | index of the prepared statement to be used with execute |
query(
string $sql, bool $dieOnError
=
false, string $msg
=
'', bool $suppress
=
false, bool $keepResult
=
false
)
:
resource | bool
Parses and runs queries
Name | Type | Description |
---|---|---|
$sql | string | SQL Statement to execute |
$dieOnError | bool | True if we want to call die if the query returns errors |
$msg | string | Message to log if error occurs |
$suppress | bool | Flag to suppress all error output unless in debug logging mode. |
$keepResult | bool | Keep query result in the object? |
Type | Description |
---|---|
resource | bool | result set or success/failure bool |
queryArray(
array $sqls, bool $dieOnError
=
false, string $msg
=
'', bool $suppress
=
false
)
:
resource | bool
Execute multiple queries one after another
Inherited from: \DBManager::queryArray()\MssqlManager::queryArray()Name | Type | Description |
---|---|---|
$sqls | array | Queries |
$dieOnError | bool | Die on error, passed to query() |
$msg | string | Error message, passed to query() |
$suppress | bool | Supress errors, passed to query() |
Type | Description |
---|---|
resource | bool | result set or success/failure bool |
quote(
string $string
)
:
string
Name | Type | Description |
---|---|---|
$string | string |
Type | Description |
---|---|
string |
quoteFormEmail(
string $string
)
:
string
Quotes a string for storing in the database
Inherited from: \DBManager::quoteFormEmail()\MssqlManager::quoteFormEmail()Name | Type | Description |
---|---|---|
$string | string |
Type | Description |
---|---|
string |
quoteTerm(
string $term
)
:
string
Name | Type | Description |
---|---|---|
$term | string |
Type | Description |
---|---|
string |
quoteType(
string $type, string $value
)
:
string
Quote value according to type Numerics aren't quoted Dates are converted and quoted Rest is just quoted
Inherited from: \DBManager::quoteType()\MssqlManager::quoteType()Name | Type | Description |
---|---|---|
$type | string | |
$value | string |
Type | Description |
---|---|
string | Quoted value |
quoted(
string $string
)
:
string
Return string properly quoted with ''
Inherited from: \DBManager::quoted()\MssqlManager::quoted()Name | Type | Description |
---|---|---|
$string | string |
Type | Description |
---|---|
string |
registerError(
string $userMessage, string $message, bool $dieOnError
=
false
)
:
void
Register database error If die-on-error flag is set, logs the message and dies, otherwise sets last_error to the message
Inherited from: \DBManager::registerError()\MssqlManager::registerError()Name | Type | Description |
---|---|---|
$userMessage | string | Message from function user |
$message | string | Message from SQL driver |
$dieOnError | bool |
removePatternFromSQL(
string $p_sql, string $strip_beg, string $strip_end, string $patt
=
'patt'
)
:
void
Searches for begginning and ending characters. It places contents into an array and replaces contents in original string. This is used to account for use of nested functions while aliasing column names
Inherited from: \MssqlManager::removePatternFromSQL()Name | Type | Description |
---|---|---|
$p_sql | string | SQL statement |
$strip_beg | string | Beginning character |
$strip_end | string | Ending character |
$patt | string | Optional, pattern to |
renameColumnSQL(
string $tablename, string $column, string $newname
)
:
void
Name | Type | Description |
---|---|---|
$tablename | string | |
$column | string | |
$newname | string |
renameIndexDefs(
array $old_definition, array $new_definition, string $table_name
)
:
string
Renames an index using fields definition
Inherited from: \DBManager::renameIndexDefs()\MssqlManager::renameIndexDefs()Name | Type | Description |
---|---|---|
$old_definition | array | |
$new_definition | array | |
$table_name | string |
Type | Description |
---|---|
string | SQL statement |
repairTable(
\SugarBean $bean, bool $execute
=
true
)
:
string
Implements repair of a db table for a bean.
Inherited from: \DBManager::repairTable()\MssqlManager::repairTable()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$execute | bool | true if we want the action to take place, false if we just want the sql returned |
Type | Description |
---|---|
string | SQL statement or empty string, depending upon $execute |
repairTableParams(
string $tablename, array $fielddefs, array $indices, bool $execute
=
true, string $engine
=
null
)
:
string
Builds the SQL commands that repair a table structure
Inherited from: \DBManager::repairTableParams()\MssqlManager::repairTableParams()Name | Type | Description |
---|---|---|
$tablename | string | |
$fielddefs | array | Field definitions, in vardef format |
$indices | array | Index definitions, in vardef format |
$execute | bool | optional, true if we want the queries executed instead of returned |
$engine | string | optional, MySQL engine |
Type | Description |
---|---|
string |
resetQueryCount(
)
:
void
Resets the queryCount value to 0
Inherited from: \DBManager::resetQueryCount()\MssqlManager::resetQueryCount()retrieve(
\SugarBean $bean, array $where
=
array()
)
:
resource
Implements a generic retrieve for any bean identified by id
Inherited from: \DBManager::retrieve()\MssqlManager::retrieve()If we want to pass multiple values for a name, pass it as an array If where is not passed, it defaults to id of table
Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance |
$where | array | values with the keys as names of fields. |
Type | Description |
---|---|
resource | result from the query |
retrieveSQL(
\SugarBean $bean, array $where
)
:
string
Generates SQL for select statement for any bean identified by id.
Inherited from: \DBManager::retrieveSQL()\MssqlManager::retrieveSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$where | array | where conditions in an array |
Type | Description |
---|---|
string | SQL Select Statement |
retrieveView(
array $beans, array $cols
=
array(), array $where
=
array()
)
:
resource
Implements a generic retrieve for a collection of beans.
Inherited from: \DBManager::retrieveView()\MssqlManager::retrieveView()These beans will be joined in the sql by the key attribute of field defs. Currently, this function does support outer joins.
Name | Type | Description |
---|---|---|
$beans | array | Sugarbean instance(s) |
$cols | array | columns to be returned with the keys as names of bean as identified by get_class of bean. Values of this array is the array of fieldDefs to be returned for a bean. If an empty array is passed, all columns are selected. |
$where | array | values with the keys as names of bean as identified by get_class of bean Each value at the first level is an array of values for that bean identified by name of fields. If we want to pass multiple values for a name, pass it as an array If where is not passed, all the rows will be returned. |
Type | Description |
---|---|
resource |
retrieveViewSQL(
array $beans, array $cols
=
array(), array $whereClause
=
array()
)
:
string
This method implements a generic sql for a collection of beans.
Inherited from: \DBManager::retrieveViewSQL()\MssqlManager::retrieveViewSQL()Currently, this function does not support outer joins.
Name | Type | Description |
---|---|---|
$beans | array | Array of values returned by get_class method as the keys and a bean as the value for that key. These beans will be joined in the sql by the key attribute of field defs. |
$cols | array | Optional, columns to be returned with the keys as names of bean as identified by get_class of bean. Values of this array is the array of fieldDefs to be returned for a bean. If an empty array is passed, all columns are selected. |
$whereClause | array | Optional, values with the keys as names of bean as identified by get_class of bean. Each value at the first level is an array of values for that bean identified by name of fields. If we want to pass multiple values for a name, pass it as an array. If where is not passed, all the rows will be returned. |
Type | Description |
---|---|
string | SQL Select Statement |
returnOrderBy(
string $sql, string $orig_order_match
)
:
string
Return the order by string to use in case the column has been aliased
Inherited from: \MssqlManager::returnOrderBy()Name | Type | Description |
---|---|---|
$sql | string | |
$orig_order_match | string |
Type | Description |
---|---|
string |
rollback(
)
:
bool
Rollsback pending changes to the database when the driver is setup to support transactions.
Inherited from: \DBManager::rollback()\MssqlManager::rollback()Note that the default implementation is applicable for transaction-less or auto commit scenarios. Since rollbacks cannot be done, this implementation always returns false.
Type | Description |
---|---|
bool | true if rollback succeeded, false if it failed |
- Abstract
save_audit_records(
object $bean, array $changes
)
:
bool
Name | Type | Description |
---|---|---|
$bean | object | Sugarbean instance |
$changes | array | changes |
Type | Description |
---|---|
bool | query result |
setAutoIncrement(
string $table, string $field_name
)
:
string
Either creates an auto increment through queries or returns sql for auto increment that can be appended to the end of column defination (mysql)
Inherited from: \MssqlManager::setAutoIncrement()Name | Type | Description |
---|---|---|
$table | string | Table name |
$field_name | string | Field name |
Type | Description |
---|---|
string |
setAutoIncrementStart(
string $table, string $field_name, int $start_value
)
:
string
Sets the next auto-increment value of a column to a specific value.
Inherited from: \MssqlManager::setAutoIncrementStart()Name | Type | Description |
---|---|---|
$table | string | Table name |
$field_name | string | Field name |
$start_value | int | Starting autoincrement value |
Type | Description |
---|---|
string |
setDieOnError(
bool $value
)
:
void
Sets the dieOnError value
Inherited from: \DBManager::setDieOnError()\MssqlManager::setDieOnError()Name | Type | Description |
---|---|---|
$value | bool |
setOptions(
array $options
)
:
\DBManager
Set database options Options are usually db-dependant and derive from $config['dbconfigoption']
Inherited from: \DBManager::setOptions()\MssqlManager::setOptions()Name | Type | Description |
---|---|---|
$options | array |
Type | Description |
---|---|
\DBManager |
setQueryLimit(
int $limit
)
:
void
This function sets the query threshold limit
Inherited from: \DBManager::setQueryLimit()\MssqlManager::setQueryLimit()Name | Type | Description |
---|---|---|
$limit | int | value of query threshold limit |
supports(
string $cap
)
:
bool
Check if this DB supports certain capability See $this->capabilities for the list
Inherited from: \DBManager::supports()\MssqlManager::supports()Name | Type | Description |
---|---|---|
$cap | string |
Type | Description |
---|---|
bool |
tableExists(
string $tableName
)
:
bool
Checks if a table with the name $tableName exists and returns true if it does or false otherwise
Inherited from: \MssqlManager::tableExists()Name | Type | Description |
---|---|---|
$tableName | string |
Type | Description |
---|---|
bool |
tablesLike(
\$like $like
)
:
array
Name | Type | Description |
---|---|---|
$like | \$like | string |
Type | Description |
---|---|
array |
track_slow_queries(
string $query
)
:
void
Tracks slow queries in the tracker database table
Inherited from: \DBManager::track_slow_queries()\MssqlManager::track_slow_queries()Name | Type | Description |
---|---|---|
$query | string | value of query to track |
truncate(
string $string, int $len
)
:
string
Truncates a string to a given length
Inherited from: \DBManager::truncate()\MssqlManager::truncate()Name | Type | Description |
---|---|---|
$string | string | |
$len | int | length to trim to |
Type | Description |
---|---|
string |
truncateTableSQL(
$name
)
:
string
Truncate table
Name | Type | Description |
---|---|---|
$name |
Type | Description |
---|---|
string |
update(
\SugarBean $bean, array $where
=
array()
)
:
bool
Implements a generic update for any bean
Inherited from: \DBManager::update()\MssqlManager::update()Name | Type | Description |
---|---|---|
$bean | \SugarBean | Sugarbean instance |
$where | array | values with the keys as names of fields. If we want to pass multiple values for a name, pass it as an array If where is not passed, it defaults to id of table |
Type | Description |
---|---|
bool | query result |
updateSQL(
\SugarBean $bean, array $where
=
array()
)
:
string
Generates SQL for update statement.
Inherited from: \DBManager::updateSQL()\MssqlManager::updateSQL()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$where | array | Optional, where conditions in an array |
Type | Description |
---|---|
string | SQL Create Table statement |
updateWhereArray(
\SugarBean $bean, array $where
=
array()
)
:
array
This method returns a where array so that it has id entry if where is not an array or is empty
Inherited from: \DBManager::updateWhereArray()\MssqlManager::updateWhereArray()Name | Type | Description |
---|---|---|
$bean | \SugarBean | SugarBean instance |
$where | array | Optional, where conditions in an array |
Type | Description |
---|---|
array |
validColumnType(
string $type
)
:
bool
returns true if the type can be mapped to a valid column type
Inherited from: \DBManager::validColumnType()\MssqlManager::validColumnType()Name | Type | Description |
---|---|---|
$type | string |
Type | Description |
---|---|
bool |
validateQuery(
string $query
)
:
bool
Name | Type | Description |
---|---|---|
$query | string |
Type | Description |
---|---|
bool |
verifyCreateTable(
string $table, string $query
)
:
string
Tests an CREATE TABLE query
Inherited from: \DBManager::verifyCreateTable()\MssqlManager::verifyCreateTable()Name | Type | Description |
---|---|---|
$table | string | The table name to get DDL |
$query | string | The query to test. |
Type | Description |
---|---|
string | Non-empty if error found |
verifyDeleteFrom(
string $table, string $query
)
:
string
Tests an DELETE FROM query
Name | Type | Description |
---|---|---|
$table | string | table The table name to get DDL |
$query | string | query The query to test. |
Type | Description |
---|---|
string | Non-empty if error found |
verifyGenericQueryRollback(
$type, $table, $query
)
:
string
Execute data manipulation statement, then roll it back
Name | Type | Description |
---|---|---|
$type | ||
$table | ||
$query |
Type | Description |
---|---|
string |
verifyInsertInto(
string $table, string $query
)
:
string
Tests an INSERT INTO query
Name | Type | Description |
---|---|---|
$table | string | table The table name to get DDL |
$query | string | query The query to test. |
Type | Description |
---|---|
string | Non-empty if error found |
verifySQLStatement(
string $query, array $skipTables
)
:
string
Verify SQl statement using per-DB verification function provided the function exists
Inherited from: \DBManager::verifySQLStatement()\MssqlManager::verifySQLStatement()Name | Type | Description |
---|---|---|
$query | string | Query to verify |
$skipTables | array | List of blacklisted tables that aren't checked |
Type | Description |
---|---|
string |
verifyUpdate(
string $table, string $query
)
:
string
Tests an UPDATE query
Name | Type | Description |
---|---|---|
$table | string | table The table name to get DDL |
$query | string | query The query to test. |
Type | Description |
---|---|
string | Non-empty if error found |