Function DatabaseConnector->query
Definitions
sources/database.php
- This function is a raw query executor.This should rarely ever be used; other functions like query_select are available. Additionally, for complex queries, it is still better to use query_parameterised as it handles escaping.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
Parameters
Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
---|---|---|---|---|---|---|---|
$query | string | No | No | required parameter | N/A | N/A | The complete SQL query |
$max | ?integer | No | No | Null | N/A | N/A | The maximum number of rows to affect (null: no limit) |
$start | integer | No | No | 0 | N/A | N/A | The start row to affect |
$fail_ok | boolean | No | No | False | N/A | N/A | Whether to output an error on failure |
$skip_safety_check | boolean | No | No | False | N/A | N/A | Whether to skip the query safety check |
$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: none) |
$field_prefix | string | No | No | Blank (empty string) | N/A | N/A | All the core fields have a prefix of this on them, so when we fiddle with language lookup we need to use this (only consider this if you're setting $lang_fields) |
Returns
- The results (null: no result set) (empty array: empty result set)
- Type: ?mixed
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* This function is a raw query executor.This should rarely ever be used; other functions like query_select are available. Additionally, for complex queries, it is still better to use query_parameterised as it handles escaping.
*
* @param string $query The complete SQL query
* @param ?integer $max The maximum number of rows to affect (null: no limit)
* @param integer $start The start row to affect
* @param boolean $fail_ok Whether to output an error on failure
* @param boolean $skip_safety_check Whether to skip the query safety check
* @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: none)
* @param string $field_prefix All the core fields have a prefix of this on them, so when we fiddle with language lookup we need to use this (only consider this if you're setting $lang_fields)
* @return ?mixed The results (null: no result set) (empty array: empty result set)
*/
public function query(string $query, ?int $max = null, int $start = 0, bool $fail_ok = false, bool $skip_safety_check = false, ?array $lang_fields = null, string $field_prefix = '')
* This function is a raw query executor.This should rarely ever be used; other functions like query_select are available. Additionally, for complex queries, it is still better to use query_parameterised as it handles escaping.
*
* @param string $query The complete SQL query
* @param ?integer $max The maximum number of rows to affect (null: no limit)
* @param integer $start The start row to affect
* @param boolean $fail_ok Whether to output an error on failure
* @param boolean $skip_safety_check Whether to skip the query safety check
* @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: none)
* @param string $field_prefix All the core fields have a prefix of this on them, so when we fiddle with language lookup we need to use this (only consider this if you're setting $lang_fields)
* @return ?mixed The results (null: no result set) (empty array: empty result set)
*/
public function query(string $query, ?int $max = null, int $start = 0, bool $fail_ok = false, bool $skip_safety_check = false, ?array $lang_fields = null, string $field_prefix = '')