php - The TP3.2 project automatically jumps to the set "ERROR_PAGE". How to check the reason?
欧阳克
欧阳克 2017-06-21 10:11:03
0
1
782

Write a scheduled task to prepare to access the address regularly to complete the function of matching brands.
Used stuttering word segmentation to separate product titles
No problem running locally. When running online, if only one product is found, there is no problem. Multiple entries will automatically jump to "ERROR_PAGE" in the configuration file. There is no record in the Log file. Now I don't know how to check the cause of this problem and can't find a solution.
It should be a problem caused by looping, but I don’t know where the problem lies?
Attached are the relevant codes:

$quan_lists = M("Quan")->field('id,title')->where(array("fromtype" => array("gt", 0),"addtime" => array("gt", $limit_time)))->limit(20)->order("id desc")->select();
$productLogic = tkD("Product", "Logic");
$searchLogic = tkD('Search', 'Logic');
if(!empty($quan_lists)) {
    foreach($quan_lists as $quan) {
        //分词结果
        $aTags = $productLogic->jieba($quan['title']);
        if (empty($aTags)) {
            continue;
        }
        $like_zh_map = $like_en_map = $condition = $map = array();
            foreach($aTags as $tag) {
                if(preg_match("/^[0-9a-zA-Z\s]+$/", $tag)) {
                            $like_en_map[] = "{$tag}%";
                        } else {
                            $like_zh_map[] = "{$tag}%";
                        }
                    }
                    if(count($like_zh_map) > 0) {
                        $condition['zh_name'] = array('like', $like_zh_map, 'OR');
                    }
                    if(count($like_en_map) > 0) {
                        $condition['en_name'] = array('like', $like_en_map, 'OR');
                    }
                    if(count($like_zh_map) > 0 && count($like_en_map) > 0) {
                        $condition['_logic'] = 'or';
                    }
                    $map['_complex'] = $condition;
                    $map['status']  = 1;
                    $aDatas = M('Brand')->field('id,zh_name,en_name')->where($map)->find();
                    if(empty($aDatas)) {
                        continue;
                    } else {
                        M("Quan")->where(array("id" => $quan['id']))->save(array("brand_id" => intval($aDatas["id"])));
                        $searchLogic->searchupdate(2, $quan['id']); //更新搜索引擎
                    }
                }
            }
public function jieba($title)
    {
        if (empty($title)) {
            return false;
        }
        ini_set('memory_limit', '200M');//吃内存

        import('Vendor/jieba/src/vendor/multi-array/MultiArray', '', '.php');
        import('Vendor/jieba/src/vendor/multi-array/Factory/MultiArrayFactory', '', '.php');
        import('Vendor/jieba/src/class/Jieba', '', '.php');
        import('Vendor/jieba/src/class/Finalseg', '', '.php');
        \Fukuball\Jieba\Jieba::init(array('dict' => 'small'));
        \Fukuball\Jieba\Finalseg::init();

        $aSeglist = \Fukuball\Jieba\Jieba::cut($title, false);
        if ($aSeglist) {
            $aTags = array();
            foreach ($aSeglist as $str) {
                if (is_numeric($str)) {
                    continue;
                } elseif (mb_strlen($str, 'utf8') < 2) {
                    continue;
                } else {
                    $aTags[] = $str;
                }
            }
            return $aTags;
        } else {
            return false;
        }
    }
欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(1)
漂亮男人

When segmenting words:
ini_set('memory_limit', '200M')
This code seems to have some problems

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!