Mysql data generation in skymvc website Test-PHP source code

Source: Internet
Author: User
Mysql data generation in skymvc website test jumps to [1] [full screen preview]
 $ V) {unset ($ _ SESSION [$ k]) ;}$ this-> onIncrement ();} public function getNum ($ table) {// set the number of records required by the table $ cf = array ("article" => 500000, "test" => 300000, "test2" => 300000 ,); if (! Isset ($ cf [$ table]) {return 300000;} else {return $ cf [$ table] ;}} public function onAutoDelete () {set_time_limit (0 ); ob_implicit_flush (true); $ res = M ("article")-> query ("show tables"); $ data = M ("article")-> fetch_array (PDO :: FETCH_NUM); $ this-> loadClass ("spider"); if ($ data) {$ uk = 0; foreach ($ data as $ k => $ t) {$ tables [] = $ t [0]; $ urls [$ uk] [] = "http ://". $ _ SERVER ['http _ host']. "/index. php? M = test_mysql & a = delete & table = ". str_replace (TABLE_PRE, "", $ t [0]); if ($ k % $ this-> maxThreads ==( $ this-> maxThreads-1 )) {$ uk ++ ;}} echo "start of deletion
"; Echo'

0

Script var I = 0; var it = setInterval (function () {I ++; document. querySelector ("# aid "). innerHTML = "executed" + I + "seconds";}, 1000); script '; foreach ($ urls as $ k => $ us) {echo "th ". $ k. "section
"; Flush (); @ ob_flush (); $ this-> spider-> start ($ us, function ($ data) {echo $ data ['URL']."
". $ Data ['content']."
"; Flush (); @ ob_flush () ;}, 600) ;}} echo" end of this deletion
"; Flush (); @ ob_flush (); echo" script setTimeout (function () {window. location. reload () ;}, 1000); script ";}public function onDelete () {$ table = get ('table', 'H'); M ($ table) -> query ("delete from ". table ($ table ). "where 1 = 1 limit 50000"); echo "delete $ table success";}/* update auto-increment id */public function onIncrement () {$ res = M ("article")-> query ("show tables"); $ data = M ("article")-> fetch_array (PDO: FETCH_NUM ); if ($ data) {foreach ($ Data as $ k => $ t) {$ table = str_replace (TABLE_PRE, "", $ t [0]); M ($ table) -> query ("alter table 'sky _". $ table. "'auto_increment = 1;") ;}} echo "update increment";} public function onAutoInsert () {set_time_limit (0); ob_implicit_flush (true ); $ res = M ("article")-> query ("show tables"); $ data = M ("article")-> fetch_array (PDO: FETCH_NUM ); $ tables = array (); if ($ data) {$ uk = 0; foreach ($ data as $ k => $ t) {$ tables [] = $ t [0]; $ urls [$ uk] [] = "h Ttp: // ". $ _ SERVER ['http _ host']."/index. php? M = test_mysql & a = insert & table = ". str_replace (TABLE_PRE, "", $ t [0]); if ($ k % $ this-> maxThreads ==( $ this-> maxThreads-1 )) {$ uk ++ ;}$ this-> loadClass ("spider"); echo "starts
"; Echo'

0

Script var I = 0; var it = setInterval (function () {I ++; document. querySelector ("# aid "). innerHTML = "executed" + I + "seconds";}, 1000); script '; foreach ($ urls as $ k => $ us) {echo "th ". $ k. "section
"; Flush (); @ ob_flush (); $ this-> spider-> start ($ us, function ($ data) {echo $ data ['URL']."
". $ Data ['content']."
"; Flush (); @ ob_flush () ;}, 600) ;}echo" ended
"; Flush (); @ ob_flush ();} echo" script setTimeout (function () {window. location. reload () ;}, 1000); script ";}public function onInsert ($ table ='') {$ inauto = true; if (! $ Table) {set_time_limit (0); $ inauto = false;} $ table = $ table? $ Table: get ('table', 'H'); if (! $ Table) {$ table = "article";} $ fields = $ this-> getFIelds ($ table ); // why do I only execute the command to 266 buckets? $ jnum = $ this-> getNum ($ table); for ($ j = 0; $ j <$ this-> maxrow; $ j ++) {$ rscount = M ($ table)-> selectOne (array ("fields" => "count (1 )")); if ($ rscount> $ jnum) {echo $ table. "The test data is sufficient.
"; Break;} if (! Inauto) {echo "inserting number". $ j. "thousands
"; Flush (); @ ob_flush (); ob_clean () ;}$ data = array (); for ($ I = 0; $ I <1000; $ I ++) {$ data [] = $ this-> dbPost ($ table);} $ SQL = "insert ". table ($ table ). "(". implode (",", $ fields ). ") values"; foreach ($ data as $ k = >$ v) {if ($ k> 0) {$ SQL. = "," ;}$ SQL. = "(". _ implode ($ v ). ")";} $ SQL. = ";"; M ($ table)-> query ($ SQL); unset ($ data); unset ($ SQL);} echo "success ";} public function getFIelds ($ table) {$ fields = M ($ table)-> getFields (); foreach ($ fi Elds as $ k =>$ v) {if ($ k = 0) continue; $ data [] = $ v ['field'];} return $ data ;} public function dbPost ($ table, $ msg = '') {if (isset ($ _ SESSION [" field _". $ table]) {$ fields = $ _ SESSION ["field _". $ table];} else {$ fields = M ($ table)-> getFields (); $ _ SESSION ["field _". $ table] = $ fields;} $ msg = $ msg? $ Msg: "skymvc is". date ("Ymdhis"). "the most intimate". date ("Ymdhis"). "php development framework. come and use it! "; $ Data = array (); $ gid = $ this-> getId ($ table); foreach ($ fields as $ k => $ v) {if ($ k = 0) continue; if (preg_match ("/tinyint/I", $ v ['type']) {$ data [$ v ['field'] = rand ();} elseif (preg_match ("/int/I", $ v ['type']) {if ($ v ['field'] = 'Dateline ') {$ data [$ v ['field'] = time ();} else {$ data [$ v ['field'] = $ gid;} elseif (preg_match ("/decimal/I", $ v ['type']) {$ data [$ v ['field'] = rand ();} elseif (preg_match ("/datetime/I", $ v ['Ty Pe ']) {$ data [$ v ['field'] = date ("Y-m-d H: I: s ");} elseif ($ v ['field'] = 'bstatus') {$ data [$ v ['field'] = 1 ;} else {$ data [$ v ['field'] = $ msg;} return $ data;} public function getId ($ table) {if (! Isset ($ _ SESSION ["autoid _ $ table"]) {$ _ SESSION ["autoid _ $ table"] = 1 ;} else {$ _ SESSION ["autoid _ $ table"] ++;} return $ _ SESSION ["autoid _ $ table"] ;}}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.