include/database/MysqliManager.php

Show: inherited
Table of Contents

\MysqliManager

Package: SugarCRM

MySQL manager implementation for mysqli extension

Parent(s)
\MysqlManager < \DBManager

Properties

Propertyprotected  $backendFunctions= 'array( 'free_result' => 'mysqli_free_result', 'close' => 'mysqli_close', 'row_count' => 'mysqli_num_rows', 'affected_row_count' => 'mysqli_affected_rows', )'

Default valuearray( 'free_result' => 'mysqli_free_result', 'close' => 'mysqli_close', 'row_count' => 'mysqli_num_rows', 'affected_row_count' => 'mysqli_affected_rows', )Details
Type
n/a
See
\DBManager::$backendFunctions  
Propertyprotected  $capabilities= 'array( "affected_rows" => true, "select_rows" => true, "inline_keys" => true, "create_user" => true, "fulltext" => true, "collation" => true, "create_db" => true, "disable_keys" => true, )'
inherited

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.)

Inherited from: \MysqlManager::$$capabilities
Default valuearray( "affected_rows" => true, "select_rows" => true, "inline_keys" => true, "create_user" => true, "fulltext" => true, "collation" => true, "create_db" => true, "disable_keys" => true, )Details
Type
n/a
Inherited_from
\MysqlManager::$$capabilities  
Propertypublicresource  $database= 'null'
inherited

Name of database

Inherited from: \DBManager::$$database\MysqlManager::$$database
Default valuenullDetails
Type
resource
Inherited_from
\DBManager::$$database  
Inherited_from
\MysqlManager::$$database  
Propertypublic  $dbName= ''MySQL''
inheritedInherited from: \MysqlManager::$$dbName
Default value'MySQL'Details
Type
n/a
Inherited_from
\MysqlManager::$$dbName  
Propertypublic  $dbType= ''mysql''

Default value'mysql'Details
Type
n/a
See
\DBManager::$dbType  
Propertyprotected  $dieOnError= 'false'
inherited

Indicates whether we should die when we get an error from the DB

Inherited from: \DBManager::$$dieOnError\MysqlManager::$$dieOnError
Default valuefalseDetails
Type
n/a
Inherited_from
\DBManager::$$dieOnError  
Inherited_from
\MysqlManager::$$dieOnError  
Propertyprotected  $encode= 'true'
inherited

Indicates whether we should html encode the results from a query by default

Inherited from: \DBManager::$$encode\MysqlManager::$$encode
Default valuetrueDetails
Type
n/a
Inherited_from
\DBManager::$$encode  
Inherited_from
\MysqlManager::$$encode  
Propertyprotectedarray  $index_descriptions= 'array()'
staticinherited

Index descriptions

Inherited from: \DBManager::$$index_descriptions\MysqlManager::$$index_descriptions
Default valuearray()Details
Type
array
Inherited_from
\DBManager::$$index_descriptions  
Inherited_from
\MysqlManager::$$index_descriptions  
Propertypublicstring  $label= ''LBL_MYSQLI''

Driver name label, for install

Default value'LBL_MYSQLI'Details
Type
string
Propertyprotected  $lastResult= ''
inherited

Registry of available result sets

Inherited from: \DBManager::$$lastResult\MysqlManager::$$lastResult
Details
Type
n/a
Inherited_from
\DBManager::$$lastResult  
Inherited_from
\MysqlManager::$$lastResult  
Propertyprotected  $last_error= 'false'
inherited

Last error message from the DB backend

Inherited from: \DBManager::$$last_error\MysqlManager::$$last_error
Default valuefalseDetails
Type
n/a
Inherited_from
\DBManager::$$last_error  
Inherited_from
\MysqlManager::$$last_error  
Propertyprotected\Logger  $log= ''
inherited

PHP Logger

Inherited from: \DBManager::$$log\MysqlManager::$$log
Details
Type
\Logger
Inherited_from
\DBManager::$$log  
Inherited_from
\MysqlManager::$$log  
Propertyprotectedarray  $maxNameLengths= 'array( 'table' => 64, 'column' => 64, 'index' => 64, 'alias' => 256 )'
inherited

Maximum length of identifiers

Inherited from: \MysqlManager::$$maxNameLengths
Default valuearray( 'table' => 64, 'column' => 64, 'index' => 64, 'alias' => 256 )Details
Type
array
Inherited_from
\MysqlManager::$$maxNameLengths  
Propertyprotectedarray  $options= 'array()'
inherited

Database options

Inherited from: \DBManager::$$options\MysqlManager::$$options
Default valuearray()Details
Type
array
Inherited_from
\DBManager::$$options  
Inherited_from
\MysqlManager::$$options  
Propertyprotected  $preparedTokens= 'array()'
inherited

Array of prepared statements and their correspoding parsed tokens

Inherited from: \DBManager::$$preparedTokens\MysqlManager::$$preparedTokens
Default valuearray()Details
Type
n/a
Inherited_from
\DBManager::$$preparedTokens  
Inherited_from
\MysqlManager::$$preparedTokens  
Propertypublicint  $priority= '10'

DB driver priority Higher priority drivers override lower priority ones

Default value10Details
Type
int
Propertyprivate  $queryCount= '0'
staticinherited

Current query count

Inherited from: \DBManager::$$queryCount\MysqlManager::$$queryCount
Default value0Details
Type
n/a
Inherited_from
\DBManager::$$queryCount  
Inherited_from
\MysqlManager::$$queryCount  
Propertyprivate  $queryLimit= '0'
staticinherited

Query threshold limit

Inherited from: \DBManager::$$queryLimit\MysqlManager::$$queryLimit
Default value0Details
Type
n/a
Inherited_from
\DBManager::$$queryLimit  
Inherited_from
\MysqlManager::$$queryLimit  
Propertyprotected  $query_time= '0'
inherited

Records the execution time of the last query

Inherited from: \DBManager::$$query_time\MysqlManager::$$query_time
Default value0Details
Type
n/a
Inherited_from
\DBManager::$$query_time  
Inherited_from
\MysqlManager::$$query_time  
Propertyprotected  $standardQueries= 'array( 'ALTER TABLE' => 'verifyAlterTable', 'DROP TABLE' => 'verifyDropTable', 'CREATE TABLE' => 'verifyCreateTable', 'INSERT INTO' => 'verifyInsertInto', 'UPDATE' => 'verifyUpdate', 'DELETE FROM' => 'verifyDeleteFrom', )'
Default valuearray( '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
\MysqlManager::$$standardQueries  
Propertyprotectedarray  $table_descriptions= 'array()'
staticinherited

Table descriptions

Inherited from: \DBManager::$$table_descriptions\MysqlManager::$$table_descriptions
Default valuearray()Details
Type
array
Inherited_from
\DBManager::$$table_descriptions  
Inherited_from
\MysqlManager::$$table_descriptions  
Propertyprotected\TimeDate  $timedate= ''
inherited

TimeDate instance

Inherited from: \DBManager::$$timedate\MysqlManager::$$timedate
Details
Type
\TimeDate
Inherited_from
\DBManager::$$timedate  
Inherited_from
\MysqlManager::$$timedate  
Propertyprotectedarray  $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', )'
inherited

Type classification into: - int - bool - float - date

Inherited from: \DBManager::$$type_class\MysqlManager::$$type_class
Default valuearray( '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
\MysqlManager::$$type_class  
Propertyprotectedarray  $type_map= 'array( 'int' => 'int', 'double' => 'double', 'float' => 'float', 'uint' => 'int unsigned', 'ulong' => 'bigint unsigned', 'long' => 'bigint', 'short' => 'smallint', 'varchar' => 'varchar', 'text' => 'text', 'longtext' => 'longtext', 'date' => 'date', 'enum' => 'varchar', 'relate' => 'varchar', 'multienum'=> 'text', 'html' => 'text', 'longhtml' => 'longtext', 'datetime' => 'datetime', 'datetimecombo' => 'datetime', 'time' => 'time', 'bool' => 'bool', 'tinyint' => 'tinyint', 'char' => 'char', 'blob' => 'blob', 'longblob' => 'longblob', 'currency' => 'decimal(26,6)', 'decimal' => 'decimal', 'decimal2' => 'decimal', 'id' => 'char(36)', 'url' => 'varchar', 'encrypt' => 'varchar', 'file' => 'varchar', 'decimal_tpl' => 'decimal(%d, %d)', )'
inherited

Type names map

Inherited from: \MysqlManager::$$type_map
Default valuearray( 'int' => 'int', 'double' => 'double', 'float' => 'float', 'uint' => 'int unsigned', 'ulong' => 'bigint unsigned', 'long' => 'bigint', 'short' => 'smallint', 'varchar' => 'varchar', 'text' => 'text', 'longtext' => 'longtext', 'date' => 'date', 'enum' => 'varchar', 'relate' => 'varchar', 'multienum'=> 'text', 'html' => 'text', 'longhtml' => 'longtext', 'datetime' => 'datetime', 'datetimecombo' => 'datetime', 'time' => 'time', 'bool' => 'bool', 'tinyint' => 'tinyint', 'char' => 'char', 'blob' => 'blob', 'longblob' => 'longblob', 'currency' => 'decimal(26,6)', 'decimal' => 'decimal', 'decimal2' => 'decimal', 'id' => 'char(36)', 'url' => 'varchar', 'encrypt' => 'varchar', 'file' => 'varchar', 'decimal_tpl' => 'decimal(%d, %d)', )Details
Type
array
Inherited_from
\MysqlManager::$$type_map  
Propertypublic  $variant= ''mysqli''
Default value'mysqli'Details
Type
n/a

Methods

methodpublic__construct( ) : void
inherited

Create DB Driver

Inherited from: \DBManager::__construct()\MysqlManager::__construct()
methodpublic__get( string $p ) : mixed
inherited

Wrapper for those trying to access the private and protected class members directly

Inherited from: \DBManager::__get()\MysqlManager::__get()
Parameters
Name Type Description
$p string

var name

Returns
Type Description
mixed
methodprotected_emptyValue( mixed $val, string $type ) : bool
inherited

Check if the value is empty value for this type

Inherited from: \DBManager::_emptyValue()\MysqlManager::_emptyValue()
Parameters
Name Type Description
$val mixed

Value

$type string

Type (one of vardef types)

Returns
Type Description
bool true if the value if empty
methodprotected_getBooleanValue( mixed $val ) : bool
inherited

Get truth value for boolean type Allows 'off' to mean false, along with all 'empty' values

Inherited from: \DBManager::_getBooleanValue()\MysqlManager::_getBooleanValue()
Parameters
Name Type Description
$val mixed
Returns
Type Description
bool
methodpublicaddColumn( string $tablename, array $fieldDefs ) : bool
inherited

Adds a column to table identified by field def.

Inherited from: \DBManager::addColumn()\MysqlManager::addColumn()
Parameters
Name Type Description
$tablename string
$fieldDefs array
Returns
Type Description
bool query result
methodpublicaddColumnSQL( string $tablename, array $fieldDefs ) : string
inherited

This method generates sql for adding a column to table identified by field def.

Inherited from: \DBManager::addColumnSQL()\MysqlManager::addColumnSQL()
Parameters
Name Type Description
$tablename string
$fieldDefs array
Returns
Type Description
string SQL statement
methodpublicaddIndexes( string $tablename, array $indexes, bool $execute = true ) : string
inherited

Adds a new indexes

Inherited from: \DBManager::addIndexes()\MysqlManager::addIndexes()
Parameters
Name Type Description
$tablename string
$indexes array

indexes to add

$execute bool

true if we want to execute the returned sql statement

Returns
Type Description
string SQL statement
methodpublicadd_drop_constraint( string $table, array $definition, bool $drop = false ) : string
inherited

Generates alter constraint statement given a table name and vardef definition.

Inherited from: \MysqlManager::add_drop_constraint()

Supports both adding and droping a constraint.

Parameters
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

Returns
Type Description
string SQL statement
Details
See
\DBManager::add_drop_constraint()  
methodpublicalterColumn( string $tablename, array $newFieldDef, bool $ignoreRequired = false ) : bool
inherited

Alters old column identified by oldFieldDef to new fieldDef.

Inherited from: \DBManager::alterColumn()\MysqlManager::alterColumn()
Parameters
Name Type Description
$tablename string
$newFieldDef array
$ignoreRequired bool

optional, true if we are ignoring this being a required field

Returns
Type Description
bool query result
methodpublicalterColumnSQL( string $tablename, array $newFieldDefs, bool $ignorerequired = false ) : string | array
inherited

This method genrates sql for altering old column identified by oldFieldDef to new fieldDef.

Inherited from: \DBManager::alterColumnSQL()\MysqlManager::alterColumnSQL()
Parameters
Name Type Description
$tablename string
$newFieldDefs array
$ignorerequired bool

Optional, true if we should ignor this being a required field

Returns
Type Description
string | array SQL statement(s)
methodpublicarrayQuote( array $array ) : array
inherited

Quote the strings of the passed in array

Inherited from: \DBManager::arrayQuote()\MysqlManager::arrayQuote()

The array must only contain strings

Parameters
Name Type Description
$array array
Returns
Type Description
array Quoted strings
methodprotectedauditSQL( \SugarBean $bean, array $changes ) : string
inherited

Generate query for audit table

Inherited from: \DBManager::auditSQL()\MysqlManager::auditSQL()
Parameters
Name Type Description
$bean \SugarBean

SugarBean that was changed

$changes array

List of changes, contains 'before' and 'after'

Returns
Type Description
string Audit table INSERT query
methodpubliccanInstall( ) : mixed
inherited

Check DB version

Inherited from: \MysqlManager::canInstall()
Returns
Type Description
mixed
Details
See
\DBManager::canInstall()  
methodprotectedchangeColumnSQL( string $tablename, array $fieldDefs, string $action, bool $ignoreRequired = false ) : string | array
inherited

Generates the SQL for changing columns

Inherited from: \MysqlManager::changeColumnSQL()
Parameters
Name Type Description
$tablename string
$fieldDefs array
$action string
$ignoreRequired bool

Optional, true if we should ignor this being a required field

Returns
Type Description
string | array
Details
See
\DBManager::changeColumnSQL()  
methodpubliccheckConnection( ) : void
inherited

Checks the current connection; if it is not connected then reconnect

Inherited from: \DBManager::checkConnection()\MysqlManager::checkConnection()
methodpubliccheckError( string $msg = '', bool $dieOnError = false ) : bool
inherited

Checks for error happening in the database

Inherited from: \DBManager::checkError()\MysqlManager::checkError()
Parameters
Name Type Description
$msg string

message to prepend to the error message

$dieOnError bool

true if we want to die immediately on error

Returns
Type Description
bool True if there was an error
methodpubliccheckPrivilege( string $privilege ) : bool
inherited

Check if connecting user has certain privilege

Inherited from: \DBManager::checkPrivilege()\MysqlManager::checkPrivilege()
Parameters
Name Type Description
$privilege string
Returns
Type Description
bool Privilege allowed?
methodprotectedcheckQuery( string $sql ) : bool
inherited

Scans order by to ensure that any field being ordered by is.

Inherited from: \MysqlManager::checkQuery()

It will throw a warning error to the log file - fatal if slow query logging is enabled

Parameters
Name Type Description
$sql string

query to be run

Returns
Type Description
bool true if an index is found false otherwise
Details
See
\DBManager::checkQuery()  
methodprotectedcolumnSQLRep( array $fieldDefs, bool $ignoreRequired = false, string $tablename ) : string
inherited

Returns SQL defintions for all columns in a table

Inherited from: \DBManager::columnSQLRep()\MysqlManager::columnSQLRep()
Parameters
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

Returns
Type Description
string SQL column definitions
methodpubliccommit( ) : bool
inherited

Commits pending changes to the database when the driver is setup to support transactions.

Inherited from: \DBManager::commit()\MysqlManager::commit()

Note that the default implementation is applicable for transaction-less or auto commit scenarios.

Returns
Type Description
bool true if commit succeeded, false if it failed
Details
Abstract
 
methodpubliccompareFieldInTables( string $name, string $table1, string $table2 ) : array
inherited

Compare a field in two tables

Inherited from: \DBManager::compareFieldInTables()\MysqlManager::compareFieldInTables()
Parameters
Name Type Description
$name string

field name

$table1 string
$table2 string
Returns
Type Description
array array with keys 'msg','table1','table2'
methodpubliccompareVarDefs( array $fielddef1, array $fielddef2, bool $ignoreName = false ) : bool
inherited

Compares two vardefs

Inherited from: \DBManager::compareVarDefs()\MysqlManager::compareVarDefs()
Parameters
Name Type Description
$fielddef1 array

This is from the database

$fielddef2 array

This is from the vardef

$ignoreName bool

Ignore name-only differences?

Returns
Type Description
bool true if they match, false if they don't
methodpublicconcat( string $table, array $fields, string $space = ' ' ) : string
inherited

Returns the database string needed for concatinating multiple database strings together

Inherited from: \DBManager::concat()\MysqlManager::concat()
Parameters
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

Returns
Type Description
string
methodpublicconnect( 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

Parameters
Name Type Description
$configOptions array
$dieOnError boolean
Details
See
\DBManager::connect()  
methodpublicconvert( string $string, string $type, array $additional_parameters = array() ) : string
inherited

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

Inherited from: \MysqlManager::convert()
Parameters
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

Returns
Type Description
string
Details
See
\DBManager::convert()  
methodpubliccountQuery( ) : void
inherited

This function increments the global $sql_queries variable

Inherited from: \DBManager::countQuery()\MysqlManager::countQuery()
methodprotectedcreateConstraintSql( \SugarBean $bean ) : array
inherited

returns SQL to create constraints or indices

Inherited from: \DBManager::createConstraintSql()\MysqlManager::createConstraintSql()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

Returns
Type Description
array list of SQL statements
methodpubliccreateDatabase( string $dbname ) : void
inherited

Create a database

Inherited from: \MysqlManager::createDatabase()
Parameters
Name Type Description
$dbname string
methodpubliccreateDbUser( string $database_name, string $host_name, string $user, string $password ) : void
inherited

Create DB user

Inherited from: \MysqlManager::createDbUser()
Parameters
Name Type Description
$database_name string
$host_name string
$user string
$password string
methodpubliccreateIndex( \SugarBean $bean, array $fieldDefs, string $name, bool $unique = true ) : bool
inherited

Creates an index identified by name on the given fields.

Inherited from: \DBManager::createIndex()\MysqlManager::createIndex()
Parameters
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

Returns
Type Description
bool query result
methodpubliccreateIndexSQL( \SugarBean $bean, array $fields, string $name, bool $unique = true ) : string
inherited

Generates SQL for create index statement for a bean.

Inherited from: \DBManager::createIndexSQL()\MysqlManager::createIndexSQL()
Parameters
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

Returns
Type Description
string SQL Select Statement
methodpubliccreateTable( \SugarBean $bean ) : void
inherited

Implements creation of a db table for a bean.

Inherited from: \DBManager::createTable()\MysqlManager::createTable()

NOTE: does not handle out-of-table constraints, use createConstraintSQL for that

Parameters
Name Type Description
$bean \SugarBean

Sugarbean instance

methodpubliccreateTableParams( string $tablename, array $fieldDefs, array $indices, string $engine = null ) : bool
inherited

Implements creation of a db table

Inherited from: \DBManager::createTableParams()\MysqlManager::createTableParams()
Parameters
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

Returns
Type Description
bool success value
methodpubliccreateTableSQL( \SugarBean $bean ) : string
inherited

Generates sql for create table statement for a bean.

Inherited from: \MysqlManager::createTableSQL()

NOTE: does not handle out-of-table constraints, use createConstraintSQL for that

Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

Returns
Type Description
string SQL Create Table statement
Details
See
\DBManager::createTableSQL()  
methodpubliccreateTableSQLParams( string $tablename, array $fieldDefs, array $indices, string $engine = null ) : string
inherited

Generates sql for create table statement for a bean.

Inherited from: \MysqlManager::createTableSQLParams()
Parameters
Name Type Description
$tablename string
$fieldDefs array
$indices array
$engine string

optional, MySQL engine to use

Returns
Type Description
string SQL Create Table statement
methodpublicdbExists( string $dbname ) : void
inherited

Check if certain database exists

Inherited from: \MysqlManager::dbExists()
Parameters
Name Type Description
$dbname string
methodpublicdelete( \SugarBean $bean, array $where = array() ) : bool
inherited

Implements a generic delete for any bean identified by id

Inherited from: \DBManager::delete()\MysqlManager::delete()
Parameters
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

Returns
Type Description
bool query result
methodpublicdeleteAutoIncrement( string $table, string $field_name ) : void
inherited

Deletes an auto increment

Inherited from: \DBManager::deleteAutoIncrement()\MysqlManager::deleteAutoIncrement()
Parameters
Name Type Description
$table string

tablename

$field_name string
Details
Abstract
 
methodpublicdeleteColumn( \SugarBean $bean, array $fieldDefs ) : bool
inherited

Deletes a column identified by fieldDef.

Inherited from: \DBManager::deleteColumn()\MysqlManager::deleteColumn()
Parameters
Name Type Description
$bean \SugarBean

SugarBean containing the field

$fieldDefs array

Vardef definition of the field

Returns
Type Description
bool query result
methodpublicdeleteColumnSQL( \SugarBean $bean, array $fieldDefs ) : string
inherited

This method generates sql that deletes a column identified by fieldDef.

Inherited from: \DBManager::deleteColumnSQL()\MysqlManager::deleteColumnSQL()
Parameters
Name Type Description
$bean \SugarBean

Sugarbean instance

$fieldDefs array
Returns
Type Description
string SQL statement
methodpublicdeleteSQL( \SugarBean $bean, array $where ) : string
inherited

Generates SQL for delete statement identified by id.

Inherited from: \DBManager::deleteSQL()\MysqlManager::deleteSQL()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

$where array

where conditions in an array

Returns
Type Description
string SQL Update Statement
methodprotecteddescribeField( string $name, string $tablename ) : array
inherited

Returns the field description for a given field in table

Inherited from: \DBManager::describeField()\MysqlManager::describeField()
Parameters
Name Type Description
$name string
$tablename string
Returns
Type Description
array
methodprotecteddescribeIndex( string $name, string $tablename ) : array
inherited

Returns the index description for a given index in table

Inherited from: \DBManager::describeIndex()\MysqlManager::describeIndex()
Parameters
Name Type Description
$name string
$tablename string
Returns
Type Description
array
methodpublicdisableKeys( string $tableName ) : void
inherited

Disable keys on the table

Inherited from: \MysqlManager::disableKeys()
Parameters
Name Type Description
$tableName string
Details
Abstract
 
methodpublicdisconnect( ) : void

Disconnects from the database

Also handles any cleanup needed

methodpublicdisconnectAll( ) : void
methodpublicdropColumnSQL( string $tablename, array $fieldDefs ) : string
inherited

This method generates sql that drops a column identified by fieldDef.

Inherited from: \DBManager::dropColumnSQL()\MysqlManager::dropColumnSQL()

Designed to work like the other addColumnSQL() and alterColumnSQL() functions

Parameters
Name Type Description
$tablename string
$fieldDefs array
Returns
Type Description
string SQL statement
methodpublicdropDatabase( string $dbname ) : void
inherited

Drop a database

Inherited from: \MysqlManager::dropDatabase()
Parameters
Name Type Description
$dbname string
methodpublicdropIndexes( string $tablename, array $indexes, bool $execute = true ) : string
inherited

Drops indexes

Inherited from: \MysqlManager::dropIndexes()
Parameters
Name Type Description
$tablename string
$indexes array

indexes to drop

$execute bool

true if we want to execute the returned sql statement

Returns
Type Description
string SQL statement
methodpublicdropTable( \SugarBean $bean ) : bool
inherited

Drops the table associated with a bean

Inherited from: \DBManager::dropTable()\MysqlManager::dropTable()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

Returns
Type Description
bool query result
methodpublicdropTableName( string $name ) : bool
inherited

Drops the table by name

Inherited from: \DBManager::dropTableName()\MysqlManager::dropTableName()
Parameters
Name Type Description
$name string

Table name

Returns
Type Description
bool query result
methodpublicdropTableNameSQL( string $name ) : string
inherited

Generates SQL for dropping a table.

Inherited from: \MysqlManager::dropTableNameSQL()
Parameters
Name Type Description
$name string

table name

Returns
Type Description
string SQL statement
methodpublicdropTableSQL( \SugarBean $bean ) : string
inherited

Generates SQL for dropping a table.

Inherited from: \DBManager::dropTableSQL()\MysqlManager::dropTableSQL()
Parameters
Name Type Description
$bean \SugarBean

Sugarbean instance

Returns
Type Description
string SQL statement
methodprotecteddump_slow_queries( string $query ) : boolean
inherited

This method is called by every method that runs a query.

Inherited from: \DBManager::dump_slow_queries()\MysqlManager::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.

Parameters
Name Type Description
$query string

query to log

Returns
Type Description
boolean true if the query was logged, false otherwise
methodpublicemptyValue( string $type ) : mixed
inherited

Return representation of an empty value depending on type The value is fully quoted, converted, etc.

Inherited from: \MysqlManager::emptyValue()
Parameters
Name Type Description
$type string
Returns
Type Description
mixed Empty value
methodpublicenableKeys( string $tableName ) : void
inherited

Re-enable keys on the table

Inherited from: \MysqlManager::enableKeys()
Parameters
Name Type Description
$tableName string
Details
Abstract
 
methodpublicescape_quote( string $string ) : string
inherited

Quotes a string for storing in the database

Inherited from: \DBManager::escape_quote()\MysqlManager::escape_quote()
Parameters
Name Type Description
$string string
Returns
Type Description
string
methodpublicexecutePreparedQuery( int $stmt, array $data = array() ) : resource
inherited

Takes a prepared stmt index and the data to replace and creates the query and runs it.

Inherited from: \DBManager::executePreparedQuery()\MysqlManager::executePreparedQuery()
Parameters
Name Type Description
$stmt int

The index of the prepared statement from preparedTokens

$data array

The array of data to replace the tokens with.

Returns
Type Description
resource result set or false on error
methodprotectedextractTableName( string $query ) : string
inherited

Extract table name from a query

Inherited from: \DBManager::extractTableName()\MysqlManager::extractTableName()
Parameters
Name Type Description
$query string

SQL query

Returns
Type Description
string
methodpublicfetchByAssoc( resource $result, bool $encode = true ) : array
inherited

Fetches the next row in the query result into an associative array

Inherited from: \DBManager::fetchByAssoc()\MysqlManager::fetchByAssoc()
Parameters
Name Type Description
$result resource
$encode bool

Need to HTML-encode the result?

Returns
Type Description
array returns false if there are no more rows available to fetch
methodpublicfetchOne( string $sql, bool $dieOnError = false, string $msg = '', bool $suppress = false ) : array
inherited

Runs a query and returns a single row

Inherited from: \MysqlManager::fetchOne()
Parameters
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

Returns
Type Description
array single row from the query
methodpublicfetchRow( resource $result ) : array

Fetches the next row in the query result into an associative array

Parameters
Name Type Description
$result resource
Returns
Type Description
array returns false if there are no more rows available to fetch
Details
See
\DBManager::fetchRow()  
methodprotectedfreeDbResult( resource $dbResult ) : void

Free Database result

Parameters
Name Type Description
$dbResult resource
Details
See
\DBManager::freeDbResult()  
methodprotectedfreeResult( resource | bool $result = false ) : void
inherited

Frees out previous results

Inherited from: \DBManager::freeResult()\MysqlManager::freeResult()
Parameters
Name Type Description
$result resource | bool

optional, pass if you want to free a single result instead of all results

methodpublicfromConvert( string $string, string $type ) : string
inherited

(non-PHPdoc)

Inherited from: \MysqlManager::fromConvert()

Supported types - date - time - datetime - datetimecombo - timestamp

Parameters
Name Type Description
$string string

database string to convert

$type string

type of conversion to do

Returns
Type Description
string
Details
See
\DBManager::fromConvert()  
methodpublicfull_text_indexing_installed(  $dbname = null ) : bool
inherited

Check if the database supports fulltext indexing Note that database driver can be capable of supporting FT (see supports('fulltext)) but particular instance can still have it disabled

Inherited from: \MysqlManager::full_text_indexing_installed()
Parameters
Name Type Description
$dbname
Returns
Type Description
bool
Details
See
\DBManager::full_text_indexing_installed()  
methodpublicfull_text_indexing_setup( ) : void
Details
Abstract
 
methodpublicgenerateInsertSQL( \SugarBean $bean, string $select_query, int $start, int $count = -1, string $table, bool $is_related_query = false ) : string
inherited

Generate a set of Insert statements based on the bean given

Inherited from: \DBManager::generateInsertSQL()\MysqlManager::generateInsertSQL()
Parameters
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
Returns
Type Description
string SQL insert statement
methodpublicgetAffectedRowCount(  $result ) : int

Returns the number of rows affected by the last query

Parameters
Name Type Description
$result
Returns
Type Description
int
methodpublicgetAutoIncrement( string $table, string $field_name ) : string
inherited

Returns the next value for an auto increment

Inherited from: \MysqlManager::getAutoIncrement()
Parameters
Name Type Description
$table string

tablename

$field_name string
Returns
Type Description
string
methodpublicgetAutoIncrementSQL( string $table, string $field_name ) : string
inherited

Returns the sql for the next value in a sequence

Inherited from: \DBManager::getAutoIncrementSQL()\MysqlManager::getAutoIncrementSQL()
Parameters
Name Type Description
$table string

Table name

$field_name string

Field name

Returns
Type Description
string
Details
Abstract
 
methodprotectedgetCharsetInfo( ) : array
inherited

Get list of all defined charsets

Inherited from: \MysqlManager::getCharsetInfo()
Returns
Type Description
array
methodpublicgetCollationList( ) : array
inherited

List of available collation settings

Inherited from: \MysqlManager::getCollationList()
Returns
Type Description
array
methodpublicgetColumnType( string $type ) : string
inherited

Returns the valid type for a column given the type in fieldDef

Inherited from: \DBManager::getColumnType()\MysqlManager::getColumnType()
Parameters
Name Type Description
$type string

field type

Returns
Type Description
string valid type for the given field
methodprotectedgetColumnWhereClause( string $table, array $whereArray = array() ) : string
inherited

Returns a where clause without the 'where' key word

Inherited from: \DBManager::getColumnWhereClause()\MysqlManager::getColumnWhereClause()

The clause returned does not have an 'and' at the beginning and the columns are joined by 'and'.

Parameters
Name Type Description
$table string

table name

$whereArray array

Optional, where conditions in an array

Returns
Type Description
string
methodpublicgetConstraintSql( array $indices, string $table ) : array
inherited

returns a SQL query that creates the indices as defined in metadata

Inherited from: \DBManager::getConstraintSql()\MysqlManager::getConstraintSql()
Parameters
Name Type Description
$indices array

Assoc array with index definitions from vardefs

$table string

Focus table

Returns
Type Description
array Array of SQL queries to generate indices
methodpublicgetDataChanges( \SugarBean $bean ) : array
inherited

Uses the audit enabled fields array to find fields whose value has changed.

Inherited from: \DBManager::getDataChanges()\MysqlManager::getDataChanges()

The before and after values are stored in the bean. Uses $bean->fetched_row to compare

Parameters
Name Type Description
$bean \SugarBean

Sugarbean instance that was changed

Returns
Type Description
array
methodpublicgetDatabase( ) : resource
inherited

Returns the current database handle

Inherited from: \DBManager::getDatabase()\MysqlManager::getDatabase()
Returns
Type Description
resource
methodpublicgetDbInfo( ) : array | null

Get database configuration information (DB-dependent)

Returns
Type Description
array | null
methodpublicgetDefaultCollation( ) : string
inherited

List of available collation settings

Inherited from: \MysqlManager::getDefaultCollation()
Returns
Type Description
string
methodprotectedgetEngine( object $bean ) : string
inherited

Returns the name of the engine to use or null if we are to use the default

Inherited from: \MysqlManager::getEngine()
Parameters
Name Type Description
$bean object

SugarBean instance

Returns
Type Description
string
methodprotectedgetFieldNameFromSelect( string $string ) : string
inherited

returns the field name used in a select

Inherited from: \DBManager::getFieldNameFromSelect()\MysqlManager::getFieldNameFromSelect()
Parameters
Name Type Description
$string string

SELECT query

Returns
Type Description
string
methodpublicgetFieldType( array $fieldDef ) : string
inherited

Returns the type of the variable in the field

Inherited from: \DBManager::getFieldType()\MysqlManager::getFieldType()
Parameters
Name Type Description
$fieldDef array

Vardef-format field def

Returns
Type Description
string
methodpublicgetFieldsArray( resource $result, boolean $make_lower_case = false ) : array

Returns the description of fields based on the result

Parameters
Name Type Description
$result resource
$make_lower_case boolean
Returns
Type Description
array field array
Details
See
\DBManager::getFieldsArray()  
methodpublicgetFromDummyTable( ) : string
inherited

Returns a DB specific FROM clause which can be used to select against functions.

Inherited from: \MysqlManager::getFromDummyTable()

Note that depending on the database that this may also be an empty string.

Returns
Type Description
string
methodpublicgetFulltextQuery(  $field, array $terms, array $must_terms = array(), array $exclude_terms = array() ) : void
inherited

Generate fulltext query from set of terms

Inherited from: \MysqlManager::getFulltextQuery()
Parameters
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

methodpublicgetGuidSQL( ) : string
inherited

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: \MysqlManager::getGuidSQL()

I.e. generate a unique Sugar id in a sub select of an insert statement.

Returns
Type Description
string
methodpublicgetHelper( ) : \DBManager
inherited

Returns this instance's DBHelper Actually now returns $this

Inherited from: \DBManager::getHelper()\MysqlManager::getHelper()
Returns
Type Description
\DBManager
methodpublicgetOne( string $sql, bool $dieOnError = false, string $msg = '' ) : array
inherited

Runs a query and returns a single row containing single value

Inherited from: \DBManager::getOne()\MysqlManager::getOne()
Parameters
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

Returns
Type Description
array single value from the query
methodpublicgetOption( string $option ) : mixed
inherited

Get DB option by name

Inherited from: \DBManager::getOption()\MysqlManager::getOption()
Parameters
Name Type Description
$option string

Option name

Returns
Type Description
mixed Option value or null if doesn't exist
methodpublicgetOptions( ) : array
inherited

Get DB options

Inherited from: \DBManager::getOptions()\MysqlManager::getOptions()
Returns
Type Description
array
methodpublicgetQueryCount( ) : int
staticinherited

Returns the static queryCount value

Inherited from: \DBManager::getQueryCount()\MysqlManager::getQueryCount()
Returns
Type Description
int value of the queryCount static variable
methodpublicgetQueryTime( ) : int
inherited

Returns the time the last query took to execute

Inherited from: \DBManager::getQueryTime()\MysqlManager::getQueryTime()
Returns
Type Description
int
methodpublicgetRowCount( resource $result ) : int

Returns the number of rows returned by the result

This function can't be reliably implemented on most DB, do not use it.

Parameters
Name Type Description
$result resource
Returns
Type Description
int
Details
Abstract
 
Deprecated
 
methodpublicgetScriptName( ) : string
inherited

Get DB driver name used for install/upgrade scripts

Inherited from: \DBManager::getScriptName()\MysqlManager::getScriptName()
Returns
Type Description
string
methodpublicgetSelectFieldsFromQuery( string $selectStatement ) : array
inherited

Take an SQL statement and produce a list of fields used in that select

Inherited from: \DBManager::getSelectFieldsFromQuery()\MysqlManager::getSelectFieldsFromQuery()
Parameters
Name Type Description
$selectStatement string
Returns
Type Description
array
methodpublicgetTableDescription( string $tablename, bool $reload = false ) : array
inherited

Get table description

Inherited from: \DBManager::getTableDescription()\MysqlManager::getTableDescription()
Parameters
Name Type Description
$tablename string
$reload bool

true means load from DB, false allows using cache

Returns
Type Description
array Vardef-format table description
methodpublicgetTablesArray( ) : array | false
inherited

Returns an array of tables for this database

Inherited from: \MysqlManager::getTablesArray()
Returns
Type Description
array | false an array of with table names, false if no tables found
Details
See
\DBManager::getTablesArray()  
methodpublicgetTypeParts( string $type ) : array | bool
inherited

retrieves the different components from the passed column type as it is used in the type mapping and vardefs type format: [([,])]

Inherited from: \DBManager::getTypeParts()\MysqlManager::getTypeParts()
Parameters
Name Type Description
$type string

Column type

Returns
Type Description
array | bool array containing the different components of the passed in type or false in case the type contains illegal characters
methodpublicgetValidDBName( string | array $name, bool | string $ensureUnique = false, string $type = 'column', bool $force = false ) : string | array
inherited

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()\MysqlManager::getValidDBName()
Parameters
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

Returns
Type Description
string | array Valid column name trimmed to right length and with invalid characters removed
methodprotectedgetWhereClause( \SugarBean $bean, array $whereArray = array() ) : string
inherited

This method returns a complete where clause built from the where values specified.

Inherited from: \DBManager::getWhereClause()\MysqlManager::getWhereClause()
Parameters
Name Type Description
$bean \SugarBean

SugarBean that describes the table

$whereArray array

Optional, where conditions in an array

Returns
Type Description
string
methodpublicget_columns( string $tablename ) : array
inherited

Returns definitions of all indies for passed table.

Inherited from: \MysqlManager::get_columns()

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.

Parameters
Name Type Description
$tablename string
Returns
Type Description
array
Details
See
\DBManager::get_columns()  
methodpublicget_indices( string $tablename ) : array
inherited

Returns definitions of all indies for passed table.

Inherited from: \MysqlManager::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.

Parameters
Name Type Description
$tablename string
Returns
Type Description
array
Details
See
\DBManager::get_indices()  
methodprotectedhasLimit( string $sql ) : bool
inherited

Inherited from: \MysqlManager::hasLimit()
Parameters
Name Type Description
$sql string
Returns
Type Description
bool
Details
Abstract
Check if query has LIMIT clause Relevant for now only for Mysql  
methodpublicinsert( \SugarBean $bean ) : bool
inherited

Implements a generic insert for any bean.

Inherited from: \DBManager::insert()\MysqlManager::insert()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

Returns
Type Description
bool query result
methodpublicinsertParams( string $table, array $field_defs, array $data, array $field_map = null, bool $execute = true ) : bool
inherited

Insert data into table by parameter definition

Inherited from: \DBManager::insertParams()\MysqlManager::insertParams()
Parameters
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?

Returns
Type Description
bool query result
methodpublicinsertSQL( \SugarBean $bean ) : string
inherited

Generates SQL for insert statement.

Inherited from: \DBManager::insertSQL()\MysqlManager::insertSQL()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

Returns
Type Description
string SQL Create Table statement
methodpublicinstallConfig( ) : array
inherited

Get install configuration for this DB

Inherited from: \MysqlManager::installConfig()
Returns
Type Description
array
methodpublicisBooleanType( string $type ) : bool
inherited

Check if type is boolean

Inherited from: \DBManager::isBooleanType()\MysqlManager::isBooleanType()
Parameters
Name Type Description
$type string
Returns
Type Description
bool
methodpublicisDatabaseNameValid( string $name ) : bool
inherited

Check if this DB name is valid

Inherited from: \DBManager::isDatabaseNameValid()\MysqlManager::isDatabaseNameValid()
Parameters
Name Type Description
$name string
Returns
Type Description
bool
methodprotectedisEngineEnabled( string $engine ) : bool
inherited

Returns true if the engine given is enabled in the backend

Inherited from: \MysqlManager::isEngineEnabled()
Parameters
Name Type Description
$engine string
Returns
Type Description
bool
methodpublicisFieldArray( mixed $defArray ) : bool
inherited

Checks to see if passed array is truely an array of defitions

Inherited from: \DBManager::isFieldArray()\MysqlManager::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

Parameters
Name Type Description
$defArray mixed
Returns
Type Description
bool
methodprotectedisNullable( array $vardef ) : bool
inherited

Can this field be null? Auto-increment and ID fields can not be null

Inherited from: \DBManager::isNullable()\MysqlManager::isNullable()
Parameters
Name Type Description
$vardef array
Returns
Type Description
bool
methodpublicisNumericType( string $type ) : bool
inherited

Check if type is a number

Inherited from: \DBManager::isNumericType()\MysqlManager::isNumericType()
Parameters
Name Type Description
$type string
Returns
Type Description
bool
methodprotectedisSelect( string $query ) : bool
inherited

Check if the query is a select query

Inherited from: \DBManager::isSelect()\MysqlManager::isSelect()
Parameters
Name Type Description
$query string
Returns
Type Description
bool Is query SELECT?
methodpublicisTextType( string $type ) : bool
inherited

Does this type represent text (i.e., non-varchar) value?

Inherited from: \MysqlManager::isTextType()
Parameters
Name Type Description
$type string
Returns
Type Description
bool
methodprotectedkeysSQL( array $indices, bool $alter_table = false, string $alter_action = '' ) : string
inherited

Generates SQL for key specification inside CREATE TABLE statement

Inherited from: \MysqlManager::keysSQL()

The passes array is an array of field definitions or a field definition itself. The keys generated will be either primary, foreign, unique, index or none at all depending on the setting of the "key" parameter of a field definition

Parameters
Name Type Description
$indices array
$alter_table bool
$alter_action string
Returns
Type Description
string SQL Statement
methodpubliclastDbError( ) : string | false

(non-PHPdoc)

Returns
Type Description
string | false Error message or false if no error happened
Details
See
\MysqlManager::lastDbError()  
methodpubliclastError( ) : string
inherited

Return DB error message for the last query executed

Inherited from: \DBManager::lastError()\MysqlManager::lastError()
Returns
Type Description
string Last error message
methodpubliclimitQuery( string $sql, int $start, int $count, boolean $dieOnError = false, string $msg = '', bool $execute = true ) : resource
inherited

Runs a limit query: one where we specify where to start getting records and how many to get

Inherited from: \MysqlManager::limitQuery()
Parameters
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?

Returns
Type Description
resource query result
Details
See
\DBManager::limitQuery()  
methodpubliclimitQuerySql( string $sql, int $start, int $count, bool $dieOnError = false, string $msg = '' ) : resource | bool
inherited

Return limit query based on given query

Inherited from: \DBManager::limitQuerySql()\MysqlManager::limitQuerySql()
Parameters
Name Type Description
$sql string
$start int
$count int
$dieOnError bool
$msg string
Returns
Type Description
resource | bool query result
Details
See
\DBManager::limitQuery()  
methodprotectedmakeTempTableCopy(  $table ) : void
inherited

Inherited from: \MysqlManager::makeTempTableCopy()
Parameters
Name Type Description
$table
methodpublicmassageFieldDef( array $fieldDef, string $tablename ) : array
inherited

Massages the field defintions to fill in anything else the DB backend may add

Inherited from: \MysqlManager::massageFieldDef()
Parameters
Name Type Description
$fieldDef array
$tablename string
Returns
Type Description
array
Details
See
\DBManager::massageFieldDef()  
methodpublicmassageValue( mixed $val, array $fieldDef ) : mixed
inherited

Outputs a correct string for the sql statement according to value

Inherited from: \DBManager::massageValue()\MysqlManager::massageValue()
Parameters
Name Type Description
$val mixed
$fieldDef array

field definition

Returns
Type Description
mixed
methodpublicmodifyIndexes( string $tablename, array $indexes, bool $execute = true ) : string
inherited

Modifies indexes

Inherited from: \DBManager::modifyIndexes()\MysqlManager::modifyIndexes()
Parameters
Name Type Description
$tablename string
$indexes array

indexes to modify

$execute bool

true if we want to execute the returned sql statement

Returns
Type Description
string SQL statement
methodpublicnow( ) : string
inherited

Return current time in format fit for insertion into DB (with quotes)

Inherited from: \DBManager::now()\MysqlManager::now()
Returns
Type Description
string
methodpublicnumber_of_columns( string $table_name ) : int
inherited

Returns the number of columns in a table

Inherited from: \DBManager::number_of_columns()\MysqlManager::number_of_columns()
Parameters
Name Type Description
$table_name string
Returns
Type Description
int
methodprotectedoneColumnSQLRep( array $fieldDef, bool $ignoreRequired = false, string $table = '', bool $return_as_array = false ) : string
inherited

Returns the defintion for a single column

Inherited from: \MysqlManager::oneColumnSQLRep()
Parameters
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

Returns
Type Description
string or array if $return_as_array is true
Details
See
\DBManager::oneColumnSQLRep()  
methodpublicorderByEnum( string $order_by, array $values, string $order_dir ) : string
inherited

Create ORDER BY clause for ENUM type field

Inherited from: \DBManager::orderByEnum()\MysqlManager::orderByEnum()
Parameters
Name Type Description
$order_by string

Field name

$values array

Possible enum value

$order_dir string

Order direction, ASC or DESC

Returns
Type Description
string
methodpublicpQuery( string $sql, array $data = array() ) : resource
inherited

Run both prepare and execute without the client having to run both individually.

Inherited from: \DBManager::pQuery()\MysqlManager::pQuery()
Parameters
Name Type Description
$sql string

The sql to parse

$data array

The array of data to replace the tokens with.

Returns
Type Description
resource result set or false on error
methodpublicparseFulltextQuery( string $query ) : array
inherited

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()\MysqlManager::parseFulltextQuery()
Parameters
Name Type Description
$query string
Returns
Type Description
array of 3 elements - query terms, mandatory terms and excluded terms
methodpublicpostInstall( ) : void
Details
Abstract
Code run on new database after installing  
methodpublicpreInstall( ) : void
inherited

Inherited from: \MysqlManager::preInstall()
methodpublicprepareQuery( string $sql ) : int
inherited

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()\MysqlManager::prepareQuery()
Parameters
Name Type Description
$sql string

The sql to parse

Returns
Type Description
int index of the prepared statement to be used with execute
methodpublicquery( string $sql, bool $dieOnError = false, string $msg = '', bool $suppress = false, bool $keepResult = false ) : resource

Parses and runs queries

Parameters
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

True if we want to push this result into the $lastResult array.

Returns
Type Description
resource result set
Details
See
\MysqlManager::query()  
methodpublicqueryArray( array $sqls, bool $dieOnError = false, string $msg = '', bool $suppress = false ) : resource | bool
inherited

Execute multiple queries one after another

Inherited from: \DBManager::queryArray()\MysqlManager::queryArray()
Parameters
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()

Returns
Type Description
resource | bool result set or success/failure bool
methodpublicquote( string $string ) : string

Quote string in DB-specific manner

Parameters
Name Type Description
$string string
Returns
Type Description
string
Details
See
\DBManager::quote()  
methodpublicquoteFormEmail( string $string ) : string
inherited

Quotes a string for storing in the database

Inherited from: \DBManager::quoteFormEmail()\MysqlManager::quoteFormEmail()
Parameters
Name Type Description
$string string
Returns
Type Description
string
methodprotectedquoteTerm( \unknown_type $term ) : void
inherited

Quote MySQL search term

Inherited from: \MysqlManager::quoteTerm()
Parameters
Name Type Description
$term \unknown_type
methodpublicquoteType( string $type, string $value ) : string
inherited

Quote value according to type Numerics aren't quoted Dates are converted and quoted Rest is just quoted

Inherited from: \DBManager::quoteType()\MysqlManager::quoteType()
Parameters
Name Type Description
$type string
$value string
Returns
Type Description
string Quoted value
methodpublicquoted( string $string ) : string
inherited

Return string properly quoted with ''

Inherited from: \DBManager::quoted()\MysqlManager::quoted()
Parameters
Name Type Description
$string string
Returns
Type Description
string
methodprotectedregisterError( string $userMessage, string $message, bool $dieOnError = false ) : void
inherited

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()\MysqlManager::registerError()
Parameters
Name Type Description
$userMessage string

Message from function user

$message string

Message from SQL driver

$dieOnError bool
methodpublicrenameColumnSQL( string $tablename, string $column, string $newname ) : void
inherited

(non-PHPdoc)

Inherited from: \MysqlManager::renameColumnSQL()
Parameters
Name Type Description
$tablename string
$column string
$newname string
Details
See
\DBManager::renameColumnSQL()  
methodpublicrenameIndexDefs( array $old_definition, array $new_definition, string $table_name ) : string
inherited

Renames an index using fields definition

Inherited from: \DBManager::renameIndexDefs()\MysqlManager::renameIndexDefs()
Parameters
Name Type Description
$old_definition array
$new_definition array
$table_name string
Returns
Type Description
string SQL statement
methodpublicrepairTable( \SugarBean $bean, bool $execute = true ) : string
inherited

Implements repair of a db table for a bean.

Inherited from: \DBManager::repairTable()\MysqlManager::repairTable()
Parameters
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

Returns
Type Description
string SQL statement or empty string, depending upon $execute
methodpublicrepairTableParams( string $tablename, array $fielddefs, array $indices, bool $execute = true, string $engine = null ) : string
inherited

Builds the SQL commands that repair a table structure

Inherited from: \MysqlManager::repairTableParams()
Parameters
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

Returns
Type Description
string
Details
See
\DBManager::repairTableParams()  
methodpublicresetQueryCount( ) : void
staticinherited

Resets the queryCount value to 0

Inherited from: \DBManager::resetQueryCount()\MysqlManager::resetQueryCount()
methodpublicretrieve( \SugarBean $bean, array $where = array() ) : resource
inherited

Implements a generic retrieve for any bean identified by id

Inherited from: \DBManager::retrieve()\MysqlManager::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

Parameters
Name Type Description
$bean \SugarBean

Sugarbean instance

$where array

values with the keys as names of fields.

Returns
Type Description
resource result from the query
methodpublicretrieveSQL( \SugarBean $bean, array $where ) : string
inherited

Generates SQL for select statement for any bean identified by id.

Inherited from: \DBManager::retrieveSQL()\MysqlManager::retrieveSQL()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

$where array

where conditions in an array

Returns
Type Description
string SQL Select Statement
methodpublicretrieveView( array $beans, array $cols = array(), array $where = array() ) : resource
inherited

Implements a generic retrieve for a collection of beans.

Inherited from: \DBManager::retrieveView()\MysqlManager::retrieveView()

These beans will be joined in the sql by the key attribute of field defs. Currently, this function does support outer joins.

Parameters
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.

Returns
Type Description
resource
methodpublicretrieveViewSQL( array $beans, array $cols = array(), array $whereClause = array() ) : string
inherited

This method implements a generic sql for a collection of beans.

Inherited from: \DBManager::retrieveViewSQL()\MysqlManager::retrieveViewSQL()

Currently, this function does not support outer joins.

Parameters
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.

Returns
Type Description
string SQL Select Statement
methodpublicrollback( ) : bool
inherited

Rollsback pending changes to the database when the driver is setup to support transactions.

Inherited from: \DBManager::rollback()\MysqlManager::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.

Returns
Type Description
bool true if rollback succeeded, false if it failed
Details
Abstract
 
methodpublicsave_audit_records( \SugarBean $bean, array $changes ) : bool
inherited

Saves changes to module's audit table

Inherited from: \DBManager::save_audit_records()\MysqlManager::save_audit_records()
Parameters
Name Type Description
$bean \SugarBean

Sugarbean instance that was changed

$changes array

List of changes, contains 'before' and 'after'

Returns
Type Description
bool query result
methodprotectedselectDb( string $dbname ) : void

Select database

Parameters
Name Type Description
$dbname string
methodprotectedsetAutoIncrement( string $table, string $field_name ) : string
inherited

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: \MysqlManager::setAutoIncrement()
Parameters
Name Type Description
$table string

Table name

$field_name string

Field name

Returns
Type Description
string
Details
See
\DBManager::setAutoIncrement()  
methodpublicsetAutoIncrementStart( string $table, string $field_name,  $start_value ) : string
inherited

Sets the next auto-increment value of a column to a specific value.

Inherited from: \MysqlManager::setAutoIncrementStart()
Parameters
Name Type Description
$table string

tablename

$field_name string
$start_value
Returns
Type Description
string
methodpublicsetDieOnError( bool $value ) : void
inherited

Sets the dieOnError value

Inherited from: \DBManager::setDieOnError()\MysqlManager::setDieOnError()
Parameters
Name Type Description
$value bool
methodpublicsetOptions( array $options ) : \DBManager
inherited

Set database options Options are usually db-dependant and derive from $config['dbconfigoption']

Inherited from: \DBManager::setOptions()\MysqlManager::setOptions()
Parameters
Name Type Description
$options array
Returns
Type Description
\DBManager
methodpublicsetQueryLimit( int $limit ) : void
staticinherited

This function sets the query threshold limit

Inherited from: \DBManager::setQueryLimit()\MysqlManager::setQueryLimit()
Parameters
Name Type Description
$limit int

value of query threshold limit

methodpublicsupports( string $cap ) : bool
inherited

Check if this DB supports certain capability See $this->capabilities for the list

Inherited from: \DBManager::supports()\MysqlManager::supports()
Parameters
Name Type Description
$cap string
Returns
Type Description
bool
methodpublictableExists( string $tableName ) : bool
inherited

Checks if a table with the name $tableName exists and returns true if it does or false otherwise

Inherited from: \MysqlManager::tableExists()
Parameters
Name Type Description
$tableName string
Returns
Type Description
bool
Details
See
\DBManager::tableExists()  
methodpublictablesLike( \$like $like ) : array
inherited

Get tables like expression

Inherited from: \MysqlManager::tablesLike()
Parameters
Name Type Description
$like \$like

string

Returns
Type Description
array
methodpublictruncate( string $string, int $len ) : string
inherited

Truncates a string to a given length

Inherited from: \DBManager::truncate()\MysqlManager::truncate()
Parameters
Name Type Description
$string string
$len int

length to trim to

Returns
Type Description
string
methodpublictruncateTableSQL( string $name ) : string
inherited

Generates SQL for truncating a table.

Inherited from: \DBManager::truncateTableSQL()\MysqlManager::truncateTableSQL()
Parameters
Name Type Description
$name string

table name

Returns
Type Description
string
methodpublicupdate( \SugarBean $bean, array $where = array() ) : bool
inherited

Implements a generic update for any bean

Inherited from: \DBManager::update()\MysqlManager::update()
Parameters
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

Returns
Type Description
bool query result
methodpublicupdateSQL( \SugarBean $bean, array $where = array() ) : string
inherited

Generates SQL for update statement.

Inherited from: \DBManager::updateSQL()\MysqlManager::updateSQL()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

$where array

Optional, where conditions in an array

Returns
Type Description
string SQL Create Table statement
methodprotectedupdateWhereArray( \SugarBean $bean, array $where = array() ) : array
inherited

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()\MysqlManager::updateWhereArray()
Parameters
Name Type Description
$bean \SugarBean

SugarBean instance

$where array

Optional, where conditions in an array

Returns
Type Description
array
methodpublicuserExists( string $username ) : void
inherited

Check if certain DB user exists

Inherited from: \MysqlManager::userExists()
Parameters
Name Type Description
$username string
methodpublicvalid( ) : bool

Check if this driver can be used

Returns
Type Description
bool
methodprotectedvalidColumnType( string $type ) : bool
inherited

returns true if the type can be mapped to a valid column type

Inherited from: \DBManager::validColumnType()\MysqlManager::validColumnType()
Parameters
Name Type Description
$type string
Returns
Type Description
bool
methodpublicvalidateQuery( string $query ) : bool
inherited

Check if this query is valid Validates only SELECT queries

Inherited from: \MysqlManager::validateQuery()
Parameters
Name Type Description
$query string
Returns
Type Description
bool
methodprotectedverifyAlterTable( string $table, string $query ) : string
inherited

Tests an ALTER TABLE query

Inherited from: \MysqlManager::verifyAlterTable()
Parameters
Name Type Description
$table string

table The table name to get DDL

$query string

query The query to test.

Returns
Type Description
string Non-empty if error found
methodprotectedverifyCreateTable( string $table, string $query ) : string
inherited

Tests an CREATE TABLE query

Inherited from: \DBManager::verifyCreateTable()\MysqlManager::verifyCreateTable()
Parameters
Name Type Description
$table string

The table name to get DDL

$query string

The query to test.

Returns
Type Description
string Non-empty if error found
methodpublicverifyDeleteFrom( string $table, string $query ) : string
inherited

Tests an DELETE FROM query

Inherited from: \MysqlManager::verifyDeleteFrom()
Parameters
Name Type Description
$table string

table The table name to get DDL

$query string

query The query to test.

Returns
Type Description
string Non-empty if error found
methodpublicverifyDropTable( string $table, string $query ) : string
inherited

Tests a DROP TABLE query

Inherited from: \MysqlManager::verifyDropTable()
Parameters
Name Type Description
$table string

table The table name to get DDL

$query string

query The query to test.

Returns
Type Description
string Non-empty if error found
methodprotectedverifyGenericReplaceQuery(  $querytype,  $table,  $query ) : void
inherited

Inherited from: \MysqlManager::verifyGenericReplaceQuery()
Parameters
Name Type Description
$querytype
$table
$query
methodpublicverifyInsertInto( string $table, string $query ) : string
inherited

Tests an INSERT INTO query

Inherited from: \MysqlManager::verifyInsertInto()
Parameters
Name Type Description
$table string

table The table name to get DDL

$query string

query The query to test.

Returns
Type Description
string Non-empty if error found
methodpublicverifySQLStatement( string $query, array $skipTables ) : string
inherited

Verify SQl statement using per-DB verification function provided the function exists

Inherited from: \DBManager::verifySQLStatement()\MysqlManager::verifySQLStatement()
Parameters
Name Type Description
$query string

Query to verify

$skipTables array

List of blacklisted tables that aren't checked

Returns
Type Description
string
methodpublicverifyUpdate( string $table, string $query ) : string
inherited

Tests an UPDATE query

Inherited from: \MysqlManager::verifyUpdate()
Parameters
Name Type Description
$table string

table The table name to get DDL

$query string

query The query to test.

Returns
Type Description
string Non-empty if error found
methodpublicversion( ) : string
inherited

Return's the version of the database

Inherited from: \MysqlManager::version()
Returns
Type Description
string
Details
See
\DBManager::version()  
Documentation was generated by DocBlox 0.18.1.