Example #1
0
 /**
  * 将产品信息
  */
 public function writeAction()
 {
     $di = \Phalcon\DI::getDefault();
     $di->setShared('beanstalkd', function () {
         $queue = new SocketBeanstalk(array('host' => '192.168.8.189', 'port' => 11300));
         return $queue;
     });
     $bean = $di->get("beanstalkd");
     $bean->choose('forbuyers_product_move');
     $id = 0;
     while (1) {
         echo $id . "\n";
         $proMysql = Fproduct::find(array("conditions" => "tid > ?1", "bind" => array(1 => $id), "order" => "tid asc", "limit" => 100));
         $proArr = $proMysql->toArray();
         if (empty($proArr)) {
             break;
         }
         $idArr = array();
         foreach ($proArr as $value) {
             $id = $value["tid"];
             $idArr[] = $id;
         }
         $bean->put(1024, 0, 1, json_encode($idArr));
     }
 }
Example #2
0
 /**
  * 统计下分类数量, 用于进一步的对应
  *
  * @Author   tianyunzi
  * @DateTime 2016-02-16T14:34:52+0800
  * @return   [type]                   [description]
  */
 public function countAction()
 {
     $countArr = array();
     $id = 0;
     while (1) {
         echo $id . "\n";
         $productMysql = Fproduct::find(array("conditions" => "tid > ?1", "bind" => array(1 => $id), "limit" => 100));
         $productRs = $productMysql->toArray();
         if (empty($productRs)) {
             break;
         }
         foreach ($productRs as $product) {
             $id = $product["tid"];
             $categoryid = $product["cate4"] ? $product["cate4"] : ($product["cate3"] ? $product["cate3"] : $product["cate2"]);
             if (isset($countArr[$categoryid])) {
                 $countArr[$categoryid]++;
             } else {
                 $countArr[$categoryid] = 1;
             }
         }
     }
     /** 将结果存入数据库 */
     foreach ($countArr as $key => $value) {
         if ($key == 0) {
             echo "总共有" . $value . "条产品分类不正确\n";
             continue;
         }
         $countModel = new Fcatecount();
         $countModel->save(array("categoryid" => $key, "pronum" => $value));
     }
 }