Tariqa  3.0
 All Data Structures Namespaces Files Functions Variables Enumerations
dojo_connector Class Reference

Public Member Functions

 __construct ($db, $db_file)
 select ()
 update ()
 insert ()
 delete ()

Static Public Member Functions

static getJsonUserInputPart ($json, $search)
static json2sql ($json)

Static Protected Member Functions

static dumpBadJson ($json)
static json2sql_select ($json)
static json_process_fields_update ($fields)
static json_process_fields_insert ($fields)
static json2sql_update ($json)
static json2sql_insert ($json)
static json2sql_delete ($json)

Protected Attributes

 $db = null
 $db_file

Constructor & Destructor Documentation

__construct ( db,
db_file 
)

Constructs the object

Parameters:
string$page_idThe page identifier
string$db_fileThe source file of the database json file
array$configThe configuration array public
Returns:
void

Member Function Documentation

delete ( )

Does an delete public

Returns:
array
static dumpBadJson ( json) [static, protected]

Dumps the json not in the right format exception

Parameters:
array$jsonThe json array

protected

Returns:
void
static getJsonUserInputPart ( json,
search 
) [static]

Gets the user input part from a json used to build the SQL The json array should be the same json array used in the json2sql function. The "user_input" section should be another json array in the form: {'fields: { 'variable1': [ {'as_part' => 'field_name'}, ... // If the variable is present in GET or POST, this part will be added to final sql ], 'variable2': ... }, 'tables': { 'variable1': 'string representing the from part of the select', 'variable2': ... }, 'where': { 'variable1': 'string representing the where part of the select', 'variable2': ... //Please notice the the function will not add the "and" or "or" parts. These should be present in the strings }, 'having': { 'variable1': 'string representing the having part of the select', 'variable2': ...//Please notice the the function will not add the "and" or "or" parts. These should be present in the strings }, 'order': { 'variable1': [ 'field', ..., ], 'variable2': ... } Any part is OPTIONAL, as the entire user_input section NOTE: If you want the use inputs to be escaped, then name the key with '__' as prefix.

Parameters:
array$jsonThe json array
string$searchThe part being searched (fields | tables | where | having | grouping | order | limit)

public

Returns:
array
insert ( )

Does an insert public

Returns:
array
static json2sql ( json) [static]

Constructs an SQL query from a json object The json array should have the format: { 'type': 'string (select | insert | update | delete | replace)', 'fields': [ {'as_part' => 'field_name'}, ... // For the selects OR {'field_name' => 'value'}, ... // For the updates ], 'tables': 'string representing the from part of the select', 'where': 'string representing the where part of the select [OPTIONAL]', 'having': 'string representing the having part of the select [OPTIONAL]', 'grouping': [ 'field', ..., '[OPTIONAL]' ], 'order': [ {'field_name' => 'asc|desc'}, ... //[OPTIONAL] ], 'limit' : [from, count] //[OPTIONAL], 'user_input': see the user input function [OPTIONAL] }

Parameters:
array$jsonThe json array public
Returns:
string
static json2sql_delete ( json) [static, protected]

Constructs a SQL delete from a json object For the description of the json format, see the json2sql function

Parameters:
array$jsonThe json array

protected

Returns:
string
static json2sql_insert ( json) [static, protected]

Constructs a SQL insert from a json object For the description of the json format, see the json2sql function

Parameters:
array$jsonThe json array

protected

Returns:
string
static json2sql_select ( json) [static, protected]

Constructs a SQL select from a json object For the description of the json format, see the json2sql function

Parameters:
array$jsonThe json array

protected

Returns:
string
static json2sql_update ( json) [static, protected]

Constructs a SQL update from a json object For the description of the json format, see the json2sql function

Parameters:
array$jsonThe json array

protected

Returns:
string
static json_process_fields_insert ( fields) [static, protected]

Process the fields part of an SQL insert string

Parameters:
array$fieldsThe fields part of json

protected

Returns:
string
static json_process_fields_update ( fields) [static, protected]

Process the fields part of an SQL update string

Parameters:
array$fieldsThe fields part of json

protected

Returns:
string
select ( )

Returns the rows for a select public

Returns:
array
update ( )

Does an update public

Returns:
array

Field Documentation

$db = null [protected]
$db_file [protected]

The documentation for this class was generated from the following file: