当前位置: 首页>>代码示例>>PHP>>正文


PHP data::save_item方法代码示例

本文整理汇总了PHP中data::save_item方法的典型用法代码示例。如果您正苦于以下问题:PHP data::save_item方法的具体用法?PHP data::save_item怎么用?PHP data::save_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data的用法示例。


在下文中一共展示了data::save_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: downloader

 function spider_channel($intChannelID, $strUrl)
 {
     $download = new downloader();
     $feed = new agregator_feed();
     $data = new data();
     $keyword = new keyword();
     // закачиваем ресурс
     $str_data = $download->get_resource($strUrl);
     if ($str_data == false) {
         return false;
     }
     // обрабатываем документ
     $arrData = $feed->parse($str_data);
     $arrFeed = $arrData['feed'];
     $arrItems = $arrData['items'];
     // если данные присутствуют, делаем следующее
     if ($arrFeed) {
         $arrFeed->feed_id = $intChannelID;
         $arrFeed->feed_url = $strUrl;
         $arrFeed->lastindex = date("Ymdhis");
         //$arrFeedData->feed->update = date("Ymdhis");
         // отправляем массив данных на сохранение
         $data->save_feed($arrFeed->feed_id, $arrFeed->feed_url, $arrFeed->lastindex, $arrFeed->lastbuilddate_int, $arrFeed->pubdate_int, null, $arrFeed->title, $arrFeed->link, $arrFeed->description, $arrFeed->language, $arrFeed->copyright, $arrFeed->managingeditor, $arrFeed->webmaster, $arrFeed->pubdate, $arrFeed->lastbuilddate, $arrFeed->category, $arrFeed->generator, $arrFeed->docs, $arrFeed->cloud, $arrFeed->ttl, $arrFeed->image_url, $arrFeed->image_title, $arrFeed->image_link);
         for ($intCountItems = 0, $intNumItems = count($arrItems); $intCountItems < $intNumItems; $intCountItems++) {
             unset($itemsum);
             $arrItems[$intCountItems]->feed_id = $intChannelID;
             //print_r($arrItems[$intCountItems]);
             $item_id = $data->save_item("null", $arrItems[$intCountItems]->feed_id, $arrItems[$intCountItems]->pubdate_int, $arrItems[$intCountItems]->title, $arrItems[$intCountItems]->link, $arrItems[$intCountItems]->description, $arrItems[$intCountItems]->author, $arrItems[$intCountItems]->category, $arrItems[$intCountItems]->comments, $arrItems[$intCountItems]->enclousure, $arrItems[$intCountItems]->guid, $arrItems[$intCountItems]->pubdate, $arrItems[$intCountItems]->source, addslashes(json_encode($arrItems[$intCountItems])));
             if (isset($item_id) && $item_id > 0) {
                 echo "  new item: " . $item_id . "\n";
                 // Save enclosure
                 if (isset($arrItems[$intCountItems]->enclousure['URL']) && $arrItems[$intCountItems]->enclousure['LENGTH'] > 0) {
                     $enclosure_tmp = array();
                     // TODO: Download file
                     // ...
                     $enclosure_tmp['hash_32'] = md5($arrItems[$intCountItems]->enclousure['URL']);
                     $enclosure_tmp['hash_2'] = substr($enclosure_tmp['hash_32'], 0, 2);
                     $enclosure_tmp['hash_1'] = substr($enclosure_tmp['hash_32'], 0, 1);
                     $enclosure_tmp['length'] = $arrItems[$intCountItems]->enclousure['LENGTH'];
                     $enclosure_tmp['type'] = addslashes($arrItems[$intCountItems]->enclousure['TYPE']);
                     $enclosure_tmp['url'] = addslashes($arrItems[$intCountItems]->enclousure['URL']);
                     $_e_p = "../public/static";
                     // create folder in static, static/a/ab/
                     if (!is_dir($_e_p . "/" . $enclosure_tmp['hash_1'])) {
                         mkdir($_e_p . "/" . $enclosure_tmp['hash_1']);
                     }
                     if (!is_dir($_e_p . "/" . $enclosure_tmp['hash_1'] . "/" . $enclosure_tmp['hash_2'])) {
                         mkdir($_e_p . "/" . $enclosure_tmp['hash_1'] . "/" . $enclosure_tmp['hash_2']);
                     }
                     // get file from server, save in static
                     file_put_contents($_e_p . "/" . $enclosure_tmp['hash_1'] . "/" . $enclosure_tmp['hash_2'] . "/" . $enclosure_tmp['hash_32'], file_get_contents($enclosure_tmp['url']));
                     ///$_e = file_get_contents($enclosure_tmp['url']);
                     $data->feed_item_enclosure_add($item_id, $enclosure_tmp['hash_1'], $enclosure_tmp['hash_2'], $enclosure_tmp['hash_32'], $enclosure_tmp['length'], $enclosure_tmp['type'], $enclosure_tmp['url']);
                     unset($enclosure_tmp);
                 }
                 $arr_keywords = $keyword->extract_keywords($arrItems[$intCountItems]->title . " " . $arrItems[$intCountItems]->description);
                 foreach ($arr_keywords as $k) {
                     if ($keyword->check($k) == false) {
                         $keyword_id = $keyword->save($k);
                     } else {
                         $keyword_id = $keyword->get($k);
                     }
                     if ($item_id !== 0 || $item_id !== '' || $keyword_id !== 0 || $keyword_id !== '') {
                         //	mysql_query("INSERT INTO `feed_keyword_item` (`keyword_id`,`item_id`) VALUES ('{$keyword_id}','{$item_id}')");
                     }
                 }
                 unset($arr_keywords);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:vanzhiganov,项目名称:NewsArggregator,代码行数:73,代码来源:class.crawler.php


注:本文中的data::save_item方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。