A PHP wrapper for MySQLi to be able to perform most MySQL queries in a single line of PHP code
This wrapper is pre-configured to use Smarty variables
This configuration is optional and may be replaced by other constants
more information on Smarty here: https://www.smarty.net/
Permission control has been implemented for Insert / Update / Delete Commands
function HasPermission ($PermissionName) as boolean should be somewhere in your code
where $PermissionName = CanAdd | CanAlter | CanDelete
This behaviour can be skipped by uncommenting the included HasPermission function
Smarty must be initialized before including ConnectMySQL.php
Otherwise update the following variables
MySQLAddress = MySQL Server Hostname or IP
MySQLUser = MySQL Username
MySQLPass = MySQL Password
MySQLDB = MySQL Database Name
Select all rows in a table
$table = table name as string
$columns = column names to return as array of strings
$orderby = column name as string
$direction = 'ASC' or 'DESC'
$skip = MySQL skip as integer
$limit = MySQL limit as integer (default value of 'a' omits the option)
MySQLi_SelectWhere ($table, $columns, $where, $orderby = '0', $direction = 'ASC', $skip = 0, $limit = 'a')
Select rows matching a WHERE statement
See MySQLi_Select
$where = MySQL WHERE statement as string ie: "ID = 4" or "Name = 'Nick'" !!Escape user input
MySQLi_Search ($table, $columns, $columnstocompare, $string, $searchtype = 'NATURAL LANGUAGE MODE', $skip = 0, $limit = 'a', $othercolumnstosearch = array())
Perform a search within a table
See MySQLi_Select
$columnstocompare = array of column names as string = columns to include in search
$string = search term as string
$search type = MySQL search type
Insert a single row into a table
$table = table name as string
$columns = column names as array of string
$values = values as array of string
Update a single row
$table = table name as string
$columns = column names as array of string
$values = values as array of string
$ID = primary key value of row to update as string
$primaryKey = column name of primary key as string
Delete a single row
$table = table name as string
$where = MySQL WHERE statement !!Escape user input
MySQLi_Compare ($table1, $columns, $table2, $compare1, $compare2, $where, $orderby = 'ID', $direction = 'ASC', $skip = 0, $limit = 'a') {
MySQL Select $columns from $table which are not duplicated in $table2
$columns1 = columns to compare in $table1 to $table2's $columns2
$columns2 = columns to compare in $table2 to $table1's $columns1