Skip to content

A PHP wrapper for MySQLi to be able to perform most MySQL queries in a single line of PHP code

License

Notifications You must be signed in to change notification settings

TheOddPerson/MySQLi-PHP-Wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

MySQLi-PHP-Wrapper

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

All user input should be sanitized via MySQLi_Sanitize($string)

Reference and Syntax

MySQLi_Select ($table, $columns, $orderby = '', $direction = 'ASC', $skip = 0, $limit = 'a')

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

MySQLi_Insert ($table, $columns, $values)

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

MySQLi_Update ($table, $columns, $values, $ID, $primaryKey = 'ID')

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

MySQLi_Delete ($table, $where, $Name)

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

About

A PHP wrapper for MySQLi to be able to perform most MySQL queries in a single line of PHP code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages