|
@@ -13,33 +13,23 @@ class GetPetUserWorkCommand extends CConsoleCommand{
|
|
|
set_time_limit(0);
|
|
|
$this->getPetUser();
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public function getPetUser(){
|
|
|
|
|
|
$m = new MongoClient(DB_CONNETC);
|
|
|
$count = 0;
|
|
|
- $last_index = 0;
|
|
|
$collection = $m->selectCollection('cute','pet_user');
|
|
|
-
|
|
|
- $myfile = file_get_contents(dirname(__FILE__).'/../data/petUser.json');
|
|
|
-
|
|
|
- if(!empty($myfile)){
|
|
|
- $myfile = json_decode($myfile,true);
|
|
|
- $index = intval($myfile['last_index']);
|
|
|
- } else {
|
|
|
- $cursor = $collection->find();
|
|
|
- $cursor->sort(array('id' => -1));
|
|
|
- $index = $cursor->getNext()['id'];
|
|
|
- self::writeLastIndex($index);
|
|
|
- }
|
|
|
+ $cursor = $collection->find();
|
|
|
+ $cursor->sort(array('id' => -1));
|
|
|
+ $index = $cursor->getNext()['id'];
|
|
|
if (empty($index)){
|
|
|
$index = 1;
|
|
|
}
|
|
|
|
|
|
while($index) {
|
|
|
- if($count>= 1000){
|
|
|
- self::writeLastIndex($last_index);
|
|
|
+ if($count>= 50){
|
|
|
exit;
|
|
|
}
|
|
|
$count++;
|
|
@@ -68,7 +58,6 @@ class GetPetUserWorkCommand extends CConsoleCommand{
|
|
|
|
|
|
}
|
|
|
$collection->insert($data);
|
|
|
- $last_index =$data['id'];
|
|
|
}
|
|
|
}
|
|
|
sleep(3);
|