示例#1
0
 $infos['updatetime'] = 'now()';
 $image_ids = array();
 while (1) {
     $image_path = StringOpt::spider_string($contents, 'img<![&&]>src="', '"', $contents);
     if ($image_path === null || $image_path === false || trim($image_path) == '') {
         break;
     }
     $image_path = trim($image_path);
     if (!file_exists(WEB_PATH . '/resource/' . $image_path)) {
         LogOpt::set('exception', '文中目标图片不存在', 'image_path', $image_path);
         return;
     }
     $image_id = Repository::findImageIdFromImages(array('eq' => array('path' => $image_path)));
     if ($image_id == false) {
         $full_path = WEB_PATH . '/resource/' . $image_path;
         $image_id = TechlogTools::load_image($full_path, 'article');
         if ($image_id == false) {
             LogOpt::set('exception', '添加图片到数据库失败', 'image_path', $image_path);
             return;
         }
         LogOpt::set('info', '添加图片到数据库成功', 'image_id', $image_id, 'image_path', $image_path);
         $image_ids[] = $image_id;
     }
 }
 $article = Repository::findOneFromArticle(array('eq' => array('article_id' => $article_id)));
 foreach ($infos as $key => $value) {
     $func = 'set_' . $key;
     $article->{$func}($value);
 }
 $ret = Repository::persist($article);
 if ($ret == false) {