SCHLIX\cmsSQLTable

Public Methods

public __construct(string $table_name, \SCHLIX\cmsDatabase $from_database=null, bool $populate_field_names=true)
Construct $SystemDB
public __toString()
public booltableExists()
Verify if this table exists
public q()
public arraygetFields()
Get Table columns as array - this is the raw output from MySQL
public arrayconformDataValuesToFieldTypes(array $datavalues)
The purpose of this function is type safety check. It's important and this is introduced in v2.2.0. Given a key-value array data array, conform the types to table definition for safety check (length). If the field does not exist, then it will be removed from the variable. If it violates the type constrain then it will be modified according to the database type.
public arraygetParsedFields()
Get table fields with field types parsed
public boolfieldExists(string $fieldname)
Returns true if fieldname exists
public arraygetFieldNamesAsArray()
Returns this table's column name as array from cache
public arraygetFieldNamesAsArrayKeys()
Returns this table's column name as array - set to key
public stringgetFieldNamesAsString()
Returns the list of field/column names
public arraygetPrimaryKeysAsArray()
Returns the primary key in array form
public stringgetPrimaryKeyFieldNames()
Returns a comma separated field names
public arraygetPrimaryKeyFieldNamesAsArray()
Returns an array containing field names
public arrayselectAll(string $fields=' *', string $extra_criteria='', string $sortby='', string $sortdirection='ASC', int $start, int $end, bool $add_where_clause=true, bool $force_limit=false, bool $from_cache=false)
Executes SELECT * FROM table_name WHERE ...
public arrayselectOne(string $fields=' *', string $extra_criteria='', string $sortby='', string $sortdirection='ASC', bool $add_where_clause=true, bool $force_limit=false, bool $from_cache=false)
Returns a single row from SELECT * FROM table_name WHERE ...
public stringescapeFieldNames(string $fieldnames, bool $check_if_field_exists=false)
Given a comma separated fieldnames, return them escaped with backtick
public intcount(type $field_names=' *', type $criteria='', type $from_cache=false)
An alias of SELECT COUNT(fieldnames) FROM (this->table) WHERE (criteria)
public query resultquickInsert(array $datavalues, string $insert_options=EMPTY_STRING, bool $update_if_duplicate=false, array $update_datavalues=[])
Executes INSERT INTO table_name VALUES ( ... ) ON DUPLICATE KEY UPDATE ...
public query resultquickUpdate(array $datavalues, string $unsanitized_where_condition)
Executes UPDATE table_name SET field=value WHERE ...
public searchAndReplace(string $field_name, string $search, string $replace, string $where_condition=NULL)
Performs search and replace
public query resultquickDelete(string $unsanitized_where_condition)
Executes DELETE FROM table_name WHERE ....
public arraytruncate()
Executes TRUNCATE TABLE table_name
public arrayoptimize(type $unsanitized_options=EMPTY_STRING)
Optimize MySQL table
public arrayanalyze(type $unsanitized_options=EMPTY_STRING)
Executes ANALYZE TABLE table_name
public stringshowCreateTable()
Returns the CREATE TABLE syntax of this table
public stringescapeFieldName(string $field_name)
Escape field name
public stringconvertDataValuesArrayIntoSQLForInsertOperation(array $array, bool $dont_sanitize=false)
Given a key/value pair array, returns the SQL for INSERT statement
public stringconvertDataValuesArrayIntoSQLForUpdateOperation(array $array, bool $dont_sanitize=false)
Given a key/value pair array, returns the SQL for UPDATE statement
public generateSQLSelectStatement($tablename, $fields=' *', $extra_criteria='', $sortby='', $sortdirection='ASC', $start, $end, $add_where_clause=true, $force_limit=false)