Constants

MYSQL_DRIVER

MYSQL_DRIVER

MYSQLI_DRIVER

MYSQLI_DRIVER

Properties

$FirstDimWhereOp

$FirstDimWhereOp : string

First Dimension Where Operator - You'll probably want to ignore this option. It's for reverse compatibility reasons only.

Used for joining multiple elements within the first dimension of a WHERE clause array. Can be 'AND' or 'OR'.

Type

string — Can be "AND" or "OR"

$DefaultOptions

$DefaultOptions : array

Default options for connecting. Can be overwritten at a global scope by changing this variable in your code

Currently, these are:

public static $DefaultOptions = array(
    'new_link'=>false,        //for mysqli driver, when false, persistent connections are used (recommended). for mysql driver, this is the 4th parameters for mysql_connect. see mysql_connect documentation
    'client_flags'=>null,    //for mysql driver only- this is the 5th parameters for mysql_connect. see mysql_connect documentation
    'charset'=>'utf8mb4',    //if set, OpenConnection does a mysql_set_charset() with the given option (ie 'utf8mb4'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
    'collation'=>'utf8mb4_unicode_ci',    //if set with charset, OpenConnection does a "SET NAMES..." with the given option (ie 'utf8mb4_unicode_ci'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
    'driver'=>'mysqli'        //can be 'mysql' or 'mysqli' - the PHP extension to use for sql interaction. note- PHP v5.5+ deprecates 'mysql' driver
    'timezone'=>'',            //TODO: make default '+0:00'. empty will use system default time (not recommended). use hard numbers like '+0:00' cause timezone abbreviations must be defined in mysql otherwise, otherwise they may take no effect
);

Type

array

$_connection

$_connection : 

Type

$_lastResult

$_lastResult : 

Type

$_databaseName

$_databaseName : 

Type

$_server

$_server : 

Type

$_user

$_user : 

Type

$_password

$_password : 

Type

$_connectParams

$_connectParams : 

Type

$_driver

$_driver : 

Type

$_isConnected

$_isConnected : 

Type

$_isDbSelected

$_isDbSelected : 

Type

$PHP_INT_MAX

$PHP_INT_MAX : 

Type

$PHP_INT_MAX_HALF

$PHP_INT_MAX_HALF : 

Type

Methods

__construct()

__construct(string  $server, string  $user, string  $password, string  $databaseName = null, array  $options = null) 

Constructor: pass connection values, set the db settings.

$options is an ARRAY as follows:

$options = array( //SEE self::$DefaultOptions
    'new_link'=>false,        //this is the 4th parameters for mysql_connect. see mysql_connect documentation
    'client_flags'=>null,    //this is the 5th parameters for mysql_connect. see mysql_connect documentation
    'charset'=>'utf8mb4',    //if set, OpenConnection does a mysql_set_charset() with the given option (ie 'utf8mb4'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
    'collation'=>'utf8mb4_unicode_ci',    //if set with charset, OpenConnection does a "SET NAMES..." with the given option (ie 'utf8mb4_unicode_ci'). ref: http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
    'driver'=>'mysqli',        //can be 'mysql' or 'mysqli' - the PHP extension to use for sql interaction
    'timezone'=>'',            //recommended this is set to '+0:00'. empty will use system default time (not recommended). use hard numbers like '+0:00' cause timezone abbreviations must be defined in mysql otherwise, otherwise they may take no effect
);

Parameters

string $server

The server to connect to. Ex: "localhost"

string $user

The username to connect with. Ex: "smartdb"

string $password

The password to connect with. Ex: "smartdb123"

string $databaseName

The database name to connect to.

array $options

Assoc-array of key => value options. See description above.

OpenConnection()

OpenConnection(array  $options = null) : boolean

Establishes the connection with the MySql database based off credentials and options passed to the DbManager constructor

This function is AUTOMATICALLY invoked when the first query is made. You likely won't need to call it.

$options = array(
    'skip-select-db'=>false, //doesn't do a mysql_select_db. good for creating databases and etc management
);

Parameters

array $options

See description above

Returns

boolean —

true when connected (or already connected), throws exception if there is an error

CloseConnection()

CloseConnection() : boolean

Closes the MySQL connection if connected. Note that the connection is automatically closed when the PHP script has finished executing.

Returns

boolean —

true if the connection is successfull closed, false if there is no connection to close

SetDatabaseName()

SetDatabaseName(string  $databaseName, array  $options = null) : null

Sets the database to use for this connection

Parameters

string $databaseName

The database to use for this connection

array $options

as follows:

$options = {
    'force-select-db' => false, //if true, will immediately call mysql_select_db() with the database passed to this class
}

Returns

null

GetDatabaseName()

GetDatabaseName() : string

Gets the database name in use for this connection

Returns

string —

the database name currently set for this connection

Select()

Select(array  $array_select_fields, mixed  $table, array  $array_where = '', array  $array_order = '', string  $limit = '', array  $options = null) : integer

Executes a SELECT statement on the currently selected database

$options = array(
    'distinct' => false, //if true, does a SELECT DISTINCT for the select. Note: there must only be 1 select field, otherwise an exception is thrown

    'add-column-quotes' => false, //if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
    'add-select-fields-column-quotes' => false, //if true, automatically adds `quotes` around the `column names` in select fields
    'add-where-clause-column-quotes' => false, //if true, automatically adds `quotes` around the `column names` in the where clause
    'add-order-clause-column-quotes' => false, //if true, automatically adds `quotes` around the `column names` in the order clause

    'add-dot-notation' => false, //if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
    'add-select-fields-dot-notation' => false, //if true, automatically adds dot.notation before column names in select fields
    'add-where-clause-dot-notation' => false, //if true, automatically adds dot.notation before column names in the where clause
    'add-order-clause-dot-notation' => false, //if true, automatically adds dot.notation before column names in the order clause

    'quote-numerics' => false, //if true, numerics will always be quoted in the where clause (ie "WHERE `price`='123'" instead of "WHERE `price`=123"). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
    'force-select-db' => false, //if true, will always call mysql_select_db() with the database passed to this class
);

Parameters

array $array_select_fields

The columns to select. Ex: array("CustomerId", "Name", "EmailAddress")

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $array_where

The WHERE clause of the query. Ex: array( array("CustomerId"=>5, "CustomerName"=>"Jack"), array("CustomerName"=>"Cindy") ) - ...WHERE (CustomerId=5 AND CustomerName='Jack') OR (CustomerName='Cindy')

array $array_order

The "ORDER BY" clause. Ex: array("CustomerId"=>"asc", "CustomerName"=>"desc") ... ORDER BY CustomerId ASC, CustomerName DESC

string $limit

With one argument (ie $limit="10"), the value specifies the number of rows to return from the beginning of the result set. With two arguments (ie $limit="100,10"), the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1).

array $options

An array of key=>value pairs. See description above.

Returns

integer —

Returns the number of selected rows

Insert()

Insert(mixed  $table, array  $field_val_array, array  $options = null) : integer

Executes an INSERT statement on the currently selected database

$options = array(
    'add-column-quotes' => false, //if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
    'add-dot-notation' => false, //if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
    'force-select-db' => false, //if true, will call mysql_select_db() with the database passed to this class
);

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $field_val_array

Assoc array of columnName=value of values to insert. Ex: array('Name'=>'Jack', 'EmailAddress'=>'jack@frost.com') ... INSERT INTO Customer (Name, EmailAddress) VALUES ('Jack', 'jack@frost.com')

array $options

An array of key=>value pairs. See description above.

Returns

integer —

Returns the number of inserted rows (1 or 0)

Update()

Update(mixed  $table, array  $field_val_array, array  $array_where = '', string  $limit = '', array  $options = null) : integer

Executes an UPDATE statement on the currently selected database

$options = array(
    'add-column-quotes' => false, //if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
    'add-dot-notation' => false, //if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
    'force-select-db' => false, //if true, will call mysql_select_db() with the database passed to this class
    'quote-numerics' => false, //if true, numerics will always be quoted in the where clause (ie ...WHERE `price`='123'... instead of ... WHERE `price`=123...). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
);

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $field_val_array

Assoc array of columnName=value of data to update. ex: array('col1'=>5, 'col2'=>'foo') ... UPDATE $table SET col1=5, col2='foo' ...

array $array_where

The where clause. ex: array( array("id"=>5, "col1"=>"foo"), array("col2"=>"bar") ) - ...WHERE (id=5 AND col1='foo') OR (col2='bar')

string $limit

The amount of rows to limit the update to (if any) from the beginning of the result set

array $options

An array of key=>value pairs. See description above.

Returns

integer —

Returns the number of updated rows

Delete()

Delete(mixed  $table, array  $array_where = '', string  $limit = '', array  $options = null) : integer

Executes a DELETE statement on the currently selected database

$options = array(
    'add-column-quotes' => false, //if true, overwrites any other 'column-quotes' options (below) and will add column quotes to everything
    'add-dot-notation' => false, //if true, overwrites any other 'dot-notation' options (below) and will add dot notation to everything
    'force-select-db' => false, //if true, will call mysql_select_db() with the database passed to this class
    'quote-numerics' => false, //if true, numerics will always be quoted in the where clause (ie ...WHERE `price`='123'... instead of ... WHERE `price`=123...). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
);

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $array_where

The WHERE clause. Ex: array( array("id"=>5, "col1"=>"foo"), array("col2"=>"bar") ) - ...WHERE (id=5 AND col1='foo') OR (col2='bar')

string $limit

The amount of rows to limit the delete to (if any) from the beginning of the result set

array $options

An array of key=>value pairs. See description above.

Returns

integer —

Returns the number of selected rows

Query()

Query(string  $query, array  $options = null) : mixed

Executes a query against the selected database. IT IS NOT RECOMMENDED THAT YOU USE THIS FUNCTION DIRECTLY.

$options = array(
    'force-select-db' => false, //set to true if writing a query without dot notation (database.table.field) AND your app uses multiple databases with 1 connection (ie not using the 'new_link' flag on any database connection)
    'skip-select-db' => false, //if true, will skip any call to mysql_select_db. good for creating databases and etc management
    'multi-query' => false, //(NOT SUPPORTED WITH DRIVER 'mysql') - if true, will use mysqli_multi_query. use NextResult() to iterate through each query's result set. throws an exception on error
);

Parameters

string $query

The query to execute. Ex: "SELECT * FROM Customers WHERE CustomerId=1"

array $options

An array of key=>value pairs. See description above.

Returns

mixed —

Returns the result of mysql_query() - For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource. For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

NextResult()

NextResult() : mixed

(NOT SUPPORT WITH DRIVER 'mysql') To be used with Query() and the 'multi-query' option set to true. This will get the result set of the next query in the batch from 'multi-query'. Use FetchAssoc* and FetchArray* functions to iterate over each result set of rows.

Returns true if the next result set is ready for use, false if there are no more result sets. throws an exception on error

Returns

mixed —

Returns true if the next result set is ready for use, false if there are no more result sets. throws an exception on error

FetchAssocList()

FetchAssocList() : array

Places the last query results into an array of ASSOC arrays, and returns it. Each row is an index in the array. Returns an empty array if there are no results.

Example:

Function returns an array similar to:
array(
    0 => array(
        "CustomerId" => "4",
        "EmailAddress" => "jack@frost.com",
        "Name" => "Jack",
 ),
    1 => array(
        "CustomerId" => "6",
        "EmailAddress" => "queen@muppets.com",
        "Name" => "Miss Piggy",
    ),
    ...
)

Returns

array —

An array of ASSOC arrays, and returns it. Each row is an index in the array. Returns an empty array if there are no results.

FetchArrayList()

FetchArrayList() : array

Places the last query results into an array of NON-ASSOC arrays, and returns the array. Returns an empty array if there are no results.

Example:

Function returns an array similar to:
array(
    0 => array(
        0 => "4",
        1 => "jack@frost.com",
        2 => "Jack",
    ),
    1 => array(
        0 => "6",
        1 => "queen@muppets.com",
        2 => "Miss Piggy",
    ),
    ...
);

Returns

array —

An array of NON-ASSOC arrays, and returns the array. Returns an empty array if there are no results.

FetchAssoc()

FetchAssoc() : array

Returns an ASSOC array of the last query results. Column names are the array keys. False is returned if there are no more results.

Example: if( (row = $dbManager->FetchAssoc()) ){ $row['id']...

Function returns an array similar to:

array(
        "CustomerId" => "4",
        "EmailAddress" => "jack@frost.com",
        "Name" => "Jack",
);

Returns

array —

An ASSOC array of the last query results. Column names are the array keys. False is returned if there are no more results.

FetchArray()

FetchArray() : array

Returns a NON-ASSOC array of the last query results. Array keys are numeric. False is returned if there are no more results.

Example - Function returns an array similar to:

array(
        0 => "4",
        1 => "jack@frost.com",
        2 => "Jack",
);

Returns

array —

An ASSOC array of the last query results. Column names are the array keys. False is returned if there are no more results.

NumRows()

NumRows() : integer

Returns the number of rows returned from the last query (not affected rows!). This command is only valid for statements like SELECT or SHOW that return an actual result set. To retrieve the number of rows affected by a INSERT, UPDATE, REPLACE or DELETE query, use AffectedRows()

Returns

integer —

Returns the number of rows returned from the last query

Error()

Error() : string

Returns the error text from the last MySQL function

Returns

string —

Returns the error text from the last MySQL function, or empty string ("")

InsertId()

InsertId() : integer

Returns the ID generated for an AUTO_INCREMENT column by the previous query

Returns

integer —

The ID generated for an AUTO_INCREMENT column by the previous query, or FALSE

AffectedRows()

AffectedRows() : integer

Returns the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query

Returns

integer —

Returns the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query

EscapeString()

EscapeString(string  $string, array  $options = null) : string

Runs mysql_real_escape_string() on the given $string and returns it.

Parameters

string $string

The string to run mysql_real_escape_string() on.

array $options

[optional] These options are passed to OpenConnection()

Returns

string —

Runs mysql_real_escape_string() on the given $string and returns it.

IsKeyword()

IsKeyword(string  $keyword) : mixed

Checks if the given $keyword is a special keyword (ie "OR", "AND", "<", "!=", etc) and returns the match. Returns false if $keyword is not a keyword.

Parameters

string $keyword

The keyword to check.

Returns

mixed —

The matched operator, condition, or FALSE if there is no match.

IsOperator()

IsOperator(string  $keyword) : mixed

Returns the proper operator (AND or OR) if the $keyword is an operator (ie AND or OR). Otherwise returns false.

Parameters

string $keyword

The keyword to check

Returns

mixed —

The matched operator or FALSE if there is no match

IsCondition()

IsCondition(string  $keyword) : mixed

Returns the proper condition ("<",">","!=", etc) if the $keyword is an condition. Otherwise returns false.

Parameters

string $keyword

The keyword to check

Returns

mixed —

The matched condition or FALSE if there is no match

DatabaseExists()

DatabaseExists(string  $databaseName) : boolean

Returns true if the given $databaseName exists, false otherwise.

Parameters

string $databaseName

The name of the database to check for existence

Returns

boolean —

true if the given $databaseName exists, false otherwise.

TableExists()

TableExists(string  $databaseName, string  $tableName) : boolean

Returns true if the given $tableName exists within the given $databaseName, false otherwise.

Parameters

string $databaseName

The name of the database to check for existence

string $tableName

The name of the table to check for existence within the given $databaseName

Returns

boolean —

true if the given $tableName exists within the given $databaseName, false otherwise.

DropTable()

DropTable(string  $databaseName, string  $tableName) : boolean

Removes the given $tableName from within the given $databaseName.

Parameters

string $databaseName

The database to remove the given $tableName from

string $tableName

The name of the table to remove.

Returns

boolean —

true if the table was successfully dropped or doesn't exist, false if the table exists and could not be dropped

EmptyTable()

EmptyTable(string  $databaseName, string  $tableName) : boolean

Emptys all rows from the given $tableName from within the given $databaseName.

Parameters

string $databaseName

The database containing the $tableName to empty all rows from

string $tableName

The name of the table to empty all rows from

Returns

boolean —

true if the table was successfully emptied, false if the table doesn't exist

CreateDatabase()

CreateDatabase(string  $databaseName) : integer

Returns true if the database was created, false if it already exists or was not created for some reason.

Parameters

string $databaseName

The name of the database to create

Returns

integer —

Returns true if the database was created or already exists, false if it not created for some reason

DropDatabase()

DropDatabase(string  $databaseName) : integer

Returns true if the database was dropped, false if it doesn't exist or could not be dropped for some reason.

Parameters

string $databaseName

The name of the database to drop

Returns

integer —

Returns true if the database was dropped or doesn't exist, false if it could not be dropped for some reason

CopyDatabase()

CopyDatabase(string  $sourceDatabaseName, string  $destDatabaseName, array  $options = null) : boolean

Copies all structure and data from $sourceDatabaseName to $destDatabaseName. $destDatabaseName will be created if it is not already

The database user running this command will need appropriate privileges to both databases and/or the ability to create new databases

$options = array(
    'create-tables' => true,
    'create-database' => true,
    'copy-data' => true,
    'drop-existing-tables' => false,
    'drop-existing-database' => false,
)

Parameters

string $sourceDatabaseName

The name of the source database

string $destDatabaseName

The name of the destination database. This database will be created if it is not already

array $options

An array of key-value pairs (see description above)

Returns

boolean —

true on success. May throw an exception on error.

UserExists()

UserExists(string  $username, string  $host = "localhost") : boolean

Returns true if the user exists and can connect from the given $host, false otherwise

Parameters

string $username

The username to check for existence

string $host

The host the $username can connect from

Returns

boolean —

Returns true if the user exists for the given $host, false otherwise

CreateUser()

CreateUser(string  $username, string  $password, string  $host = "localhost") : integer

Creates a SQL user with the given $username and $password, able to connect from the given $host

Parameters

string $username

The username to create

string $password

The password for the given $username

string $host

The host that the given $username can connect from

Returns

integer —

Returns the number of affected rows (1 if the user was created, 0 otherwise)

DropUser()

DropUser(string  $username, string  $host = "localhost") : integer

Drops the SQL user with the given $username, able to connect from the given $host

Parameters

string $username

The username to drop

string $host

The host that the given $username could connect from

Returns

integer —

Returns the number of affected rows (1 if the user was dropped, 0 otherwise)

ChangePassword()

ChangePassword(string  $username, string  $password, string  $host = "localhost") : integer

Changes the SQL password for the user with the given $username on the given $host

Parameters

string $username

The username to update the password on

string $password

The new password to set for this username on thie host

string $host

The host that the given $username can connect from

Returns

integer —

Returns the number of affected rows (1 if the user was created, 0 otherwise)

GrantUserPermissions()

GrantUserPermissions(  $databaseName,   $username,   $host = "localhost") : integer

Grants the given $username permission to the given $database, from the given $host

Parameters

$databaseName

The database name that the $username should be granted permission to

$username

The $username that should have permission to connect to the given $databaseName

$host

The host that the $username can connect from to connect to the given $databaseName

Returns

integer —

Returns the number of affected rows (1 if the user was granted permission, 0 otherwise)

GrantGlobalFilePermissions()

GrantGlobalFilePermissions(  $username,   $host = "localhost") : integer

Grants the given $username FILE permissions when connecting from the given $host

Parameters

$username

The username to grant FILE permissions to

$host

The host the given $username can connect from for FILE permissions

Returns

integer —

Returns the number of affected rows (1 if the user was granted permission, 0 otherwise)

RevokeUserPermissions()

RevokeUserPermissions(  $databaseName,   $username,   $host = "localhost") : integer

Revokes all permissions for the given $username to the given $databaseName, when connecting from the given $host

Parameters

$databaseName

The database name to revoke the given $username permissions from

$username

The username to revoke permissions from

$host

The host the given $username could connect from that should have permissions revoked

Returns

integer —

Returns the number of affected rows (1 if the user was revoked permissions, 0 otherwise)

GenerateWhereClause()

GenerateWhereClause(mixed  $table, array  $array_where, boolean  $dotNotation = false, boolean  $addColumnQuotes = false, array  $options = array()) : string

Prepares the WHERE clause (from $array_where) for a SQL statement

 $options = array(
     'quote-numerics' => false, //if true, numerics will always be quoted in the where clause (ie ...WHERE `price`='123'... instead of ... WHERE `price`=123...). NOTE- this is for reverse compatibility. only used if $table is a string and not a SmartTable object
 );

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $array_where
boolean $dotNotation
boolean $addColumnQuotes
array $options

See description above

Returns

string

SetDriver()

SetDriver(string  $driver) 

Sets the driver that should be used for communicating with the db

Parameters

string $driver

'mysqli' or 'mysql' ('mysql' is deprecated)

Throws

\Exception

if invalid $driver is given

SetTimezone()

SetTimezone(string  $timezone) 

Sets the timezone for the connection. Default is empty which is system time (not recommended. store as UTC).

Parameters

string $timezone

a valid mysql timezone. can use hard numbers like '+0:00' cause timezone abbreviations must be defined in mysql otherwise, otherwise they may take no effect

Throws

\Exception

if invalid $driver is in use

SetPassword()

SetPassword(string  $password) : null

Encrypts the password when stored locally so it won't be visible in most stacktraces

Parameters

string $password

The password for this database connection. It will be encrypted and set to $this->_password

Returns

null

GetPassword()

GetPassword() : string

encrypts the password when stored locally so it won't be visible in most stacktraces

Returns

string —

The decrypted password for this database connection

SelectDatabase()

SelectDatabase() : null

Internal. Does a mysql_select_db() using $this->_databaseName and $this->_connection

Returns

null

FreeResult()

FreeResult() 

frees the current result set. mostly needed for multi-query statements

OrderArrayToString()

OrderArrayToString(mixed  $table, array  $array_order, boolean  $dotNotation = false, boolean  $addColumnQuotes = false) : array

Converts a sort array of structure array("id"=>"asc", "col1"=>"desc") into a string like "ORDER BY id ASC, col1 DESC"

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $array_order
boolean $dotNotation
boolean $addColumnQuotes

Returns

array —

Returns a sort array of structure array("id"=>"asc", "col1"=>"desc") into a string like "ORDER BY id ASC, col1 DESC"

ArrayToCSV()

ArrayToCSV(mixed  $table, array  $array, boolean  $dotNotation = false, boolean  $addColumnQuotes = false) : string

Converts items in $array into a comma separated value string and returns that string

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

array $array
boolean $dotNotation
boolean $addColumnQuotes

Returns

string —

Converts items in $array into a comma separated value string and returns that string

GetDotNotation()

GetDotNotation(mixed  $table, string  $column = null, boolean  $addColumnQuotes = false) : string

Returns a string of appropriate dot-notation/column quites for the given $table and $column

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

string $column
boolean $addColumnQuotes

Returns

string —

Returns a string of appropriate dot-notation/column quites for the given $table and $column

GenerateWhereRecursive()

GenerateWhereRecursive(mixed  $table, string  $key, mixed  $val, boolean  $dotNotation = false, boolean  $addColumnQuotes = false, string  $column = '', string  $condition = '=', string  $operator = 'AND', array  $options = array(), boolean  $first = true) : string

Helper for GenerateWhereClause()

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

string $key
mixed $val
boolean $dotNotation
boolean $addColumnQuotes
string $column
string $condition
string $operator
array $options
boolean $first

Ignore this. only used for recursion

Returns

string

GenerateWhereSingle()

GenerateWhereSingle(mixed  $table, string  $column, string  $condition, string  $val, boolean  $dotNotation, boolean  $addColumnQuotes, array  $options = array()) : string

Helper for GenerateWhereRecursive()

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

string $column
string $condition
string $val
boolean $dotNotation
boolean $addColumnQuotes
array $options

Returns

string

PHP_INT_MAX()

PHP_INT_MAX() : integer

Some encrypters dont support PHP_INT_MAX. This calculates it.

Returns

integer —

PHP_INT_MAX for this machine

CastQuoteValue()

CastQuoteValue(mixed  $table, string  $column, mixed  $value, array  $options = null) : mixed

Returns the given $value with appropriate casts and quotes for SQL queries

$options = array(
    'quote-numerics' => false //for reverse compatibility. only used if $table is a string and not a SmartTable object
);

Parameters

mixed $table

The table name. Ex: "Customer". This can also be a SmartTable object- if so, data will be strongly typed and more accurate.

string $column

The column name this value is used for. Used for looking up the data type in the SmartDb

mixed $value

The value to check for quote usage

array $options

[optional] Array of function options. See description.

Returns

mixed —

Returns the given $value with appropriate casts and quotes for SQL queries

PadEncryptKey()

PadEncryptKey(  $key) : string

key must be length of 16, 24, or 32

Parameters

$key

Returns

string —

the unique encrypt key used internally

Encrypt()

Encrypt(string  $encrypt, string  $key) 

A basic encrypt function for storing the password locally in this class

Parameters

string $encrypt

text to encrypt

string $key

key to encrypt against

Decrypt()

Decrypt(string  $decrypt, string  $key) 

A basic decrypt function for storing the password locally in this class

Parameters

string $decrypt

text to decrypt

string $key

key to decrypt w