Public Member Functions | |
__construct ( $in_pdo_object, $in_access_object=NULL) | |
item_exists ( $in_id, $in_visibility_test=false) | |
get_all_visible_users () | |
see_if_user_exists ( $in_login_id) | |
tag0_is_unique ( $in_tag0, $in_classname='CO_KeyValue_CO_Collection') | |
generic_search ( $in_search_parameters=NULL, $or_search=false, $page_size=0, $initial_page=0, $and_writeable=false, $count_only=false, $ids_only=false) | |
Public Member Functions inherited from A_CO_DB | |
_instantiate_record ( $in_db_result) | |
execute_query ( $in_sql, $in_parameters=NULL, $exec_only=false) | |
get_db_backup () | |
get_access_class_by_id ( $in_id) | |
can_i_see_this_record ( $in_id) | |
get_single_raw_row_by_id ( $in_id, $and_write=false) | |
get_single_record_by_id ( $in_id, $and_write=false) | |
get_multiple_records_by_id ( $in_id_array, $and_write=false) | |
get_all_readable_records ( $open_only=false, $in_this_id=NULL) | |
get_all_writeable_records ( $in_this_id=NULL) | |
lock_record ( $in_record_id) | |
write_record ( $params_associative_array) | |
delete_record ( $id) | |
Static Public Member Functions | |
static | get_accurate_distance ( $lat1, $lon1, $lat2, $lon2) |
Uses the Vincenty calculation to determine the distance (in Kilometers) between the two given lat/long pairs (in Degrees). More... | |
Protected Member Functions | |
_location_predicate ( $in_longitude, $in_latitude, $in_radius_in_km, $and_writeable=false, $count_only=false) | |
_parse_tags ( $in_value) | |
_parse_integer_parameter ( $in_db_key, $in_value) | |
_parse_string_parameter ( $in_db_key, $in_value) | |
_parse_parameters ( $in_search_parameters=NULL, $or_search=false) | |
_build_sql_query ( $in_search_parameters=NULL, $or_search=false, $page_size=0, $initial_page=0, $and_writeable=false, $count_only=false, $ids_only=false) | |
Protected Member Functions inherited from A_CO_DB | |
_create_read_security_predicate () | |
_create_write_security_predicate () | |
_create_security_predicate ( $write=false) | |
Additional Inherited Members | |
Public Attributes inherited from A_CO_DB | |
$access_object | |
$class_description | |
$error | |
$table_name | |
Protected Attributes inherited from A_CO_DB | |
$_pdo_object | |
$_existing_record_objects | |
This is the instance class for the main "data" database.
Definition at line 38 of file co_main_data_db.class.php.
CO_Main_Data_DB::__construct | ( | $in_pdo_object, | |
$in_access_object = NULL |
|||
) |
The initializer.
$in_pdo_object | The PDO object for this database, initialized and ready. |
$in_access_object | The access object for the database. If NULL, then no login. |
Reimplemented from A_CO_DB.
Definition at line 524 of file co_main_data_db.class.php.
|
protected |
This builds up an SQL query, based on the input from the user.
$in_search_parameters | This is an associative array of terms to define the search. The keys should be:
|
$or_search | If true, then the search is very wide (OR), as opposed to narrow (AND), by default. If you specify a location, then that will always be AND, but the other fields can be OR. |
$page_size | If specified with a 1-based integer, this denotes the size of a "page" of results. NOTE: This is only applicable to MySQL or Postgres, and will be ignored if the DB is not MySQL or Postgres. |
$initial_page | This is ignored unless $page_size is greater than 0. If so, then this 0-based index will specify which page of results to return. |
$and_writeable | If true, then we only want records we can modify. |
$count_only | If true (default is false), then only a single integer will be returned, with the count of items that fit the search. |
$ids_only | If true (default is false), then the return array will consist only of integers (the object IDs). If $count_only is true, this is ignored. |
Definition at line 421 of file co_main_data_db.class.php.
References A_CO_DB\_create_security_predicate(), _location_predicate(), and _parse_parameters().
Referenced by generic_search().
|
protected |
This method creates a special SQL header that has an embedded Haversine formula. You use this in place of the security predicate.
The Haversine formula is not as accurate as the Vincenty Calculation, but is a lot less computationally intense, so we use this in SQL for a "triage."
$in_longitude | The search center longitude, in degrees. |
$in_latitude | The search center latitude, in degrees. |
$in_radius_in_km | The search radius, in Kilometers. |
$and_writeable | If true, then we only want records we can modify. |
$count_only | If true (default is false), then only a single integer will be returned, with the count of items that fit the search. |
Definition at line 124 of file co_main_data_db.class.php.
References A_CO_DB\_create_security_predicate().
Referenced by _build_sql_query().
|
protected |
This method will return an SQL statement and an empty set of parameters for an integer table column value.
$in_db_key | The table column name. |
$in_value | The value |
Definition at line 277 of file co_main_data_db.class.php.
Referenced by _parse_parameters().
|
protected |
This parses the provided parameters, and returns a WHERE clause for them.
$in_search_parameters | This is an associative array of terms to define the search. The keys should be:
|
$or_search | If true, then the search is very wide (OR), as opposed to narrow (AND), by default. If you specify a location, then that will always be AND, but the other fields can be OR. |
Definition at line 349 of file co_main_data_db.class.php.
References _parse_integer_parameter(), _parse_string_parameter(), and _parse_tags().
Referenced by _build_sql_query().
|
protected |
This method will return an SQL statement and a set of parameters for a case-insensitive string table column value.
Definition at line 309 of file co_main_data_db.class.php.
Referenced by _parse_parameters().
|
protected |
This method will return an SQL statement and a set of parameters for the tags.
$in_value | This should be an array of string. You can provide just one string, but that will always be applied to tag0. |
Definition at line 171 of file co_main_data_db.class.php.
Referenced by _parse_parameters().
CO_Main_Data_DB::generic_search | ( | $in_search_parameters = NULL , |
|
$or_search = false , |
|||
$page_size = 0 , |
|||
$initial_page = 0 , |
|||
$and_writeable = false , |
|||
$count_only = false , |
|||
$ids_only = false |
|||
) |
This is a "generic" data database search. It can be called from external user contexts, and allows a fairly generalized search of the "data" database. Sorting will be done for the values by the ID of the searched objects. "location" will be by distance from the center.
$in_search_parameters | This is an associative array of terms to define the search. The keys should be:
|
You can specify an array for any one of the values, which allows you to do an OR search for those values ($or_search does not apply. It is only for the combination of main values). If you add an element called 'use_like' ('use_like' => 1) to the end of 'access_class', 'name' or one of the 'tags', then you can use SQL-style "wildcards" (%) in your matches. If you have 'use_like', and put just a single wildcard in quotes (''), then you are saying "not-empty." NOTE: Although this is an optional parameter, failing to provide anything could return the entire readable database.
$or_search | If true, then the search is very wide (OR), as opposed to narrow (AND), by default. If you specify a location, then that will always be AND, but the other fields can be OR. |
$page_size | If specified with a 1-based integer, this denotes the size of a "page" of results. NOTE: This is only applicable to MySQL or Postgres, and will be ignored if the DB is not MySQL or Postgres. |
$initial_page | This is ignored unless $page_size is greater than 0. If so, then this 0-based index will specify which page of results to return. |
$and_writeable | If true, then we only want records we can modify. |
$count_only | If true (default is false), then only a single integer will be returned, with the count of items that fit the search. |
$ids_only | If true (default is false), then the return array will consist only of integers (the object IDs). If $count_only is true, this is ignored. |
Definition at line 650 of file co_main_data_db.class.php.
References _build_sql_query(), A_CO_DB\_instantiate_record(), A_CO_DB\execute_query(), and get_accurate_distance().
|
static |
Uses the Vincenty calculation to determine the distance (in Kilometers) between the two given lat/long pairs (in Degrees).
The Vincenty calculation is more accurate than the Haversine calculation, as it takes into account the "un-spherical" shape of the Earth, but is more computationally intense. We use this calculation to refine the Haversine "triage" in SQL.
$lat1 | This is the first point latitude (degrees). |
$lon1 | This is the first point longitude (degrees). |
$lat2 | This is the second point latitude (degrees). |
$lon2 | This is the second point longitude (degrees). |
Definition at line 50 of file co_main_data_db.class.php.
Referenced by CO_LL_Location\_km_per_degree(), and generic_search().
CO_Main_Data_DB::get_all_visible_users | ( | ) |
This is an extremely simple function that gets the ID and name (usually the display name) of user instances visible to the current login. It's goal is to be extremely fast and result in a relatively small response.
Definition at line 575 of file co_main_data_db.class.php.
References A_CO_DB\_create_read_security_predicate(), and A_CO_DB\execute_query().
CO_Main_Data_DB::item_exists | ( | $in_id, | |
$in_visibility_test = false |
|||
) |
This is a very "raw" function that simply checks to see if any item exists for a given integer ID.
This (usually) deliberately does not pass security vetting, so we're careful. It's meant to be used by collection classes for garbage collection.
$in_id | The ID of the item. |
$in_visibility_test | If true (default is false), then this will return false, even if the item exists, but cannot be seen by this user. |
Definition at line 542 of file co_main_data_db.class.php.
References A_CO_DB\_create_read_security_predicate(), and A_CO_DB\execute_query().
CO_Main_Data_DB::see_if_user_exists | ( | $in_login_id | ) |
This is a very "raw" function that simply checks to see if a user collection exists for a given login ID.
This deliberately does not pass security vetting, so we're careful.
$in_login_id | The login ID of the user. |
Definition at line 605 of file co_main_data_db.class.php.
CO_Main_Data_DB::tag0_is_unique | ( | $in_tag0, | |
$in_classname = 'CO_KeyValue_CO_Collection' |
|||
) |
$in_tag0 | The key to test (a string). |
$in_classname | This is the class to search for the key. The default is the base class. |
Definition at line 628 of file co_main_data_db.class.php.