- <?php
- class test_mysqlControl extends skymvc{
- public $maxrow=30;//每次最多生成多少千行
- public $maxThreads=10;
- public function __construct(){
- parent::__construct();
- }
- public function onDefault(){
- }
- public function onReset(){
- if(!empty($_SESSION)){
- foreach($_SESSION as $k=>$v){
- unset($_SESSION[$k]);
- }
- }
- $this->onIncrement();
- }
- public function getNum($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)){</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);
- //为什么只执行到266 百思不得其解
- $jnum=$this->getNum($table);
- for($j=0;$j<$this->maxrow;$j++){
- $rscount=M($table)->selectOne(array(
- "fields"=>" count(1)"
- ));
- if($rscount>$jnum){
- echo $table."测试数据已经够了<br>";
- break;
- }
- if(!inauto){
- echo "%
- //该片段来自于http://www.codesnippet.cn/detail/1512201615187.html
来源: http://www.codesnippet.cn/detail/1512201615187.html