Array
(
    [0] => Warning
    [1] => Undefined array key "language"
    [2] => /home/whmcsdev/public_repo/wbteampro.major-release/installation/modules/addons/wbteampro/initialize.php
    [3] => 282
)
Array
(
    [0] => Warning
    [1] => Undefined property: stdClass::$state
    [2] => /home/whmcsdev/public_repo/wbavatax.master/installation/modules/addons/wbavatax/hooks.php
    [3] => 942
)
Array
(
    [0] => Deprecated
    [1] => htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
    [2] => /home/whmcsdev/public_repo/wbavatax.master/installation/modules/addons/wbavatax/hooks.php
    [3] => 279
)
Quickly Populate an SQL Table with Fake Data - Knowledgebase - WHMCS Dev
Dev License: This installation of WHMCS is running under a Development License and is not authorized to be used for production use. Please report any cases of abuse to abuse@whmcs.com

Quickly Populate an SQL Table with Fake Data Print

  • 3

This brilliant little snippet came from Robert Eisele in Germany, whos site carries an amazing wealth of opinions on development and and code snippets.  The example has been updated to include a few other elements that we find common.  In the example we are generating a random timestamp between 2014-01-01 and 2014-01-01 + 90 days.

CREATE TABLE t1 (
  fixed_val TINYINT UNSIGNED NOT NULL,
  date_val datetime NOT NULL,
  int_val INT UNSIGNED NOT NULL
);
TRUNCATE t1;
INSERT INTO t1  
(
  fixed_val,
  date_val,
  int_val
)
SELECT
  1
  , FROM_UNIXTIME(UNIX_TIMESTAMP('2014-01-01') + (RAND() * (86400 * 90)))
  , FLOOR(RAND() * 1000)
FROM information_schema.tables
LIMIT 50;

Source: http://www.xarg.org/2012/08/running-standard-deviation-in-mysql/
Source: http://www.phpied.com/random-mysql-date/


Was this answer helpful?

« Back

Powered by WHMCompleteSolution