Function __global->make_dummy_db_row
Definitions
sources/developer_tools.php
- Generate a row of random dummy data into the database.Ideally, you should instead run the stress test loader, but this is useful for quick tests utilising specific tables in the database.You should immediately delete the rows after use.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: array
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $table | ID_TEXT | No | No | required parameter | N/A | N/A | The name of the table to generate dummy data |
| $allow_null | boolean | No | No | True | N/A | N/A | Whether to randomly save null values in nullable columns (false: a value is always saved even if nullable unless explicitly defined in $forced_values) |
| $forced_values | array | No | No | [] | N/A | N/A | A map of fields => values that should be used instead of randomness |
| $return_only | boolean | No | No | False | N/A | N/A | Whether to just return the row we would have added into the database instead of actually doing so |
Returns
- If $return_only is false, map of primary fields associated with the row created; otherwise, dummy db row which we did not actually add
- Type: array
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Generate a row of random dummy data into the database.Ideally, you should instead run the stress test loader, but this is useful for quick tests utilising specific tables in the database.You should immediately delete the rows after use.
*
* @param ID_TEXT $table The name of the table to generate dummy data
* @param boolean $allow_null Whether to randomly save null values in nullable columns (false: a value is always saved even if nullable unless explicitly defined in $forced_values)
* @param array $forced_values A map of fields => values that should be used instead of randomness
* @param boolean $return_only Whether to just return the row we would have added into the database instead of actually doing so
* @return array If $return_only is false, map of primary fields associated with the row created; otherwise, dummy db row which we did not actually add
*/
function make_dummy_db_row(string $table, bool $allow_null = true, array $forced_values = [], bool $return_only = false) : array
* Generate a row of random dummy data into the database.Ideally, you should instead run the stress test loader, but this is useful for quick tests utilising specific tables in the database.You should immediately delete the rows after use.
*
* @param ID_TEXT $table The name of the table to generate dummy data
* @param boolean $allow_null Whether to randomly save null values in nullable columns (false: a value is always saved even if nullable unless explicitly defined in $forced_values)
* @param array $forced_values A map of fields => values that should be used instead of randomness
* @param boolean $return_only Whether to just return the row we would have added into the database instead of actually doing so
* @return array If $return_only is false, map of primary fields associated with the row created; otherwise, dummy db row which we did not actually add
*/
function make_dummy_db_row(string $table, bool $allow_null = true, array $forced_values = [], bool $return_only = false) : array

