Function DatabaseConnector->query_select_value_if_there
Definitions
sources/database.php
- Get the specified value from the database, or null if there is no matching row (or if the value itself is null). This is good for detection existence of records, or for use if they might may or may not be present.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
Parameters
Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
---|---|---|---|---|---|---|---|
$table | string | No | No | required parameter | N/A | N/A | The table name |
$select | string | No | No | required parameter | N/A | N/A | The field to select |
$where_map | array | No | No | [] | N/A | N/A | The WHERE map [will all be ANDed together] |
$end | string | No | No | Blank (empty string) | N/A | N/A | Something to tack onto the end |
$fail_ok | boolean | No | No | False | N/A | N/A | Whether to allow failure (outputting a message instead of exiting completely) |
$lang_fields | ?array | No | No | Null | N/A | N/A | Extra language fields to join in for cache pre-filling / Tempcode, perhaps via the find_lang_fields function. You only need to send this if you are doing a JOIN and carefully craft your query so table field names won't conflict (null: auto-detect, if not a join) |
Returns
- The first value of the first row returned (null: nothing found, or null value found)
- Type: ?mixed
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Get the specified value from the database, or null if there is no matching row (or if the value itself is null). This is good for detection existence of records, or for use if they might may or may not be present.
*
* @param string $table The table name
* @param string $select The field to select
* @param array $where_map The WHERE map [will all be ANDed together]
* @param string $end Something to tack onto the end
* @param boolean $fail_ok Whether to allow failure (outputting a message instead of exiting completely)
* @param ?array $lang_fields Extra language fields to join in for cache pre-filling / Tempcode, perhaps via the find_lang_fields function. You only need to send this if you are doing a JOIN and carefully craft your query so table field names won't conflict (null: auto-detect, if not a join)
* @return ?mixed The first value of the first row returned (null: nothing found, or null value found)
*/
public function query_select_value_if_there(string $table, string $select, array $where_map = [], string $end = '', bool $fail_ok = false, ?array $lang_fields = null)
* Get the specified value from the database, or null if there is no matching row (or if the value itself is null). This is good for detection existence of records, or for use if they might may or may not be present.
*
* @param string $table The table name
* @param string $select The field to select
* @param array $where_map The WHERE map [will all be ANDed together]
* @param string $end Something to tack onto the end
* @param boolean $fail_ok Whether to allow failure (outputting a message instead of exiting completely)
* @param ?array $lang_fields Extra language fields to join in for cache pre-filling / Tempcode, perhaps via the find_lang_fields function. You only need to send this if you are doing a JOIN and carefully craft your query so table field names won't conflict (null: auto-detect, if not a join)
* @return ?mixed The first value of the first row returned (null: nothing found, or null value found)
*/
public function query_select_value_if_there(string $table, string $select, array $where_map = [], string $end = '', bool $fail_ok = false, ?array $lang_fields = null)