SLP_Data
extends SLPlus_BaseClass_Object
in package
The data interface helper.
Tags
Table of Contents
Properties
- $addon : object
- $collate : mixed
- $db : mixed
- $extension : mixed
- $from_slp_table : mixed
- $group_by_clause : mixed
- $had_where_clause : mixed
- $info : mixed
- $myslp : MySLP
- $order_by_array : mixed
- $order_by_clause : mixed
- $slplus : SLPlus
- $sql_statement : mixed
- $uses_myslp : bool
- $uses_slplus : bool
- $where_clause : mixed
- $slug : mixed
- $options : mixed
Methods
- __construct() : mixed
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- add_group_by_clause() : string
- Create a proper group by clause, adding the starting GROUP BY when necessary.
- add_order_by_clause() : string
- Create a proper order by clause, adding the starting ORDER BY when necessary.
- add_where_clause() : string
- Create a proper where clause, adding the starting WHERE when necessary.
- extend_order_array() : mixed
- Add new strings to the order by array property.
- extend_OrderBy() : string
- Add elements to the order by clause, adding a comma if needed.
- extend_Where() : string
- Add elements to the where clause, adding AND if needed unless OR specified.
- extend_WhereFieldMatches() : string
- Extend the database WHERE clause with a <field_name>='value' clause.
- filter_SetWhereValidLatLong() : string
- Add the valid lat/long clause to the where statement.
- get_instance() : static
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- get_Record() : mixed
- Return a record as an array based on a given SQL select statement keys and params list.
- get_SQL() : string
- Get an SQL statement for this database.
- get_Value() : string|WP_Error|null
- Return a single field as a value given SQL select statement keys and params list.
- has_extended_data() : mixed
- Are there records in the extended data table used in the join? DOES NOT EVALUATE if extended data fields exist.
- initialize() : mixed
- Initialize a new data object.
- is_Extended() : bool
- Determine if the data is extended based on whether the associated table has rows.
- reset_clauses() : mixed
- Reset the SQL additive clauses.
- reset_extended_data_flag() : mixed
- Reset and re-evaluate the has_extended_data flag.
- set_database_meta() : mixed
- Set database meta info only AFTER DB is created.
- set_properties() : mixed
- Set our properties.
- join_location_tables() : mixed
- Join the base location table to the extended data location table as needed.
- table_has_rows() : bool
- Check if a table exists and has rows
Properties
$addon
public
object
$addon
$collate
public
mixed
$collate
$db
public
mixed
$db
$extension
public
mixed
$extension
$from_slp_table
public
mixed
$from_slp_table
$group_by_clause
public
mixed
$group_by_clause
= ''
$had_where_clause
public
mixed
$had_where_clause
= \false
$info
public
mixed
$info
= array('collate' => \null, 'from_table' => \null, 'table' => \null, 'query' => \null)
$myslp
public
MySLP
$myslp
$order_by_array
public
mixed
$order_by_array
= array()
$order_by_clause
public
mixed
$order_by_clause
= ''
$slplus
public
SLPlus
$slplus
$sql_statement
public
mixed
$sql_statement
= ''
$uses_myslp
public
bool
$uses_myslp
Set to true to add a $myslp property pointing to global $myslp
$uses_slplus
public
bool
$uses_slplus
Set to true (default) if the object needs access to the SLPlus plugin object.
$where_clause
public
mixed
$where_clause
= ''
$slug
protected
mixed
$slug
$options
private
mixed
$options
= array('data_is_extended' => \null, 'has_extended_data' => \null)
Methods
__construct()
public
__construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
__get()
public
__get(string $property) : SLPlus_BaseClass_Object
Parameters
- $property : string
Return values
SLPlus_BaseClass_Object__isset()
public
__isset(string $property) : bool
Parameters
- $property : string
Return values
booladd_group_by_clause()
Create a proper group by clause, adding the starting GROUP BY when necessary.
public
add_group_by_clause(mixed $new_clause) : string
Parameters
- $new_clause : mixed
Return values
stringadd_order_by_clause()
Create a proper order by clause, adding the starting ORDER BY when necessary.
public
add_order_by_clause([mixed $new_clause = null ]) : string
Parameters
- $new_clause : mixed = null
Return values
stringadd_where_clause()
Create a proper where clause, adding the starting WHERE when necessary.
public
add_where_clause(mixed $new_clause[, string $joiner = 'AND' ]) : string
Parameters
- $new_clause : mixed
- $joiner : string = 'AND'
Return values
stringextend_order_array()
Add new strings to the order by array property.
public
extend_order_array(mixed $new_string) : mixed
Parameters
- $new_string : mixed
extend_OrderBy()
Add elements to the order by clause, adding a comma if needed.
public
extend_OrderBy(string $startwith, string $add) : string
Parameters
- $startwith : string
-
the starting order by clause
- $add : string
-
what to add
Return values
string —the extended order by with comma if needed (no ORDER BY prefix)
extend_Where()
Add elements to the where clause, adding AND if needed unless OR specified.
public
extend_Where(string $startwith, string $add[, string $operator = 'AND' ]) : string
Parameters
- $startwith : string
-
the starting where clause
- $add : string
-
what to add
- $operator : string = 'AND'
-
which operator to use to join the clause (default: AND)
Return values
string —the extended where clause
extend_WhereFieldMatches()
Extend the database WHERE clause with a <field_name>='value' clause.
public
extend_WhereFieldMatches(string $where, string $field, string $value) : string
Parameters
- $where : string
-
the current where clause
- $field : string
-
the field name
- $value : string
-
the value to compare against
Return values
string —the new where clause
filter_SetWhereValidLatLong()
Add the valid lat/long clause to the where statement.
public
filter_SetWhereValidLatLong(string $where) : string
Parameters
- $where : string
-
the current where clause without WHERE command
Return values
string —modified where clause
get_instance()
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
public
static get_instance([bool $no_global = false ][, mixed $params = array() ]) : static
Parameters
- $no_global : bool = false
-
set to true to skip assigning object to SLP global as a property.
- $params : mixed = array()
-
object init params
Return values
staticget_Record()
Return a record as an array based on a given SQL select statement keys and params list.
public
get_Record(array<string|int, string>|string $commandList[, array<string|int, mixed> $params = array() ][, int $offset = 0 ][, mixed $type = ARRAY_A ][, string $mode = 'get_row' ]) : mixed
Executes wpdb get_row using the specified SQL statement. If more than one row is returned by the query, only the specified row is returned by the function, but all rows are cached for later use. Returns NULL if no result is found
Parameters
- $commandList : array<string|int, string>|string
- $params : array<string|int, mixed> = array()
- $offset : int = 0
- $type : mixed = ARRAY_A
-
the type of object/array/etc. to return see wpdb get_row.
- $mode : string = 'get_row'
-
= get_row or get_col to fetch a single row or multiple rows of a single column
Tags
Return values
mixed —the database array_a or object.
get_SQL()
Get an SQL statement for this database.
public
get_SQL(string|array<string|int, string> $commandList) : string
Processed the commandList in order.
Usually a select followed by a where and possibly a limit or order by
DELETE o delete - delete from store locator table
SELECT o selectall - select from store locator table with additional slp_extend_get_SQL_selectall filter. o selectall_with_distance - select from store locator table with additional slp_extend_get_SQL_selectall filter and distance calculation math, requires extra parm passing on get record. o selectslid - select only the store id from store locator table.
WHERE o where_default - the default where clause that is built up by the slp_ajaxsql_where filters. o where_default_validlatlong - the default with valid lat/long check check added. o whereslid - add where + slid selector, get record requires slid to be passed
ORDER BY o orderby_default - add order by if the results of the slp_ajaxsql_orderby filter returns order by criteria. AJAX listener default is by distance asc.
Parameters
- $commandList : string|array<string|int, string>
-
a comma separated array of commands or a single command
Return values
stringget_Value()
Return a single field as a value given SQL select statement keys and params list.
public
get_Value(array<string|int, string> $commandList[, array<string|int, mixed> $params = array() ]) : string|WP_Error|null
If more than one record is returned it will only fetch the result of the first record.
Parameters
- $commandList : array<string|int, string>
- $params : array<string|int, mixed> = array()
Return values
string|WP_Error|nullhas_extended_data()
Are there records in the extended data table used in the join? DOES NOT EVALUATE if extended data fields exist.
public
has_extended_data() : mixed
NOTE: this only returns true if there are RECORDS in the extended data table used in locaiton joins. this does NOT tell you if there are extended data fields in the data structure.
TODO: make this faster by making it persistent, but make sure you catch all the extended data insert/deletes.
initialize()
Initialize a new data object.
public
initialize() : mixed
is_Extended()
Determine if the data is extended based on whether the associated table has rows.
public
is_Extended() : bool
Return values
bool —True if the table has rows and data is extended, false otherwise.
reset_clauses()
Reset the SQL additive clauses.
public
reset_clauses() : mixed
reset_extended_data_flag()
Reset and re-evaluate the has_extended_data flag.
public
reset_extended_data_flag() : mixed
set_database_meta()
Set database meta info only AFTER DB is created.
public
set_database_meta() : mixed
set_properties()
Set our properties.
public
set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
join_location_tables()
Join the base location table to the extended data location table as needed.
private
join_location_tables() : mixed
table_has_rows()
Check if a table exists and has rows
private
table_has_rows(string $table_name) : bool
Only called by \SLP_Data::is_Extended
Parameters
- $table_name : string
-
The table name to check (including prefix)
Return values
bool —True if table exists and has rows, false otherwise