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


PHP Image::select方法代码示例

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


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

示例1: uploadProducts

 public function uploadProducts($xml)
 {
     /**
      *	Formating XML structure of sent file
      */
     $doc = new \DOMDocument();
     $doc->loadXML($xml);
     $elements = $doc->getElementsByTagName('SHOPITEM');
     $data = array('IMGURLS' => [], 'SHOP_ID' => 1);
     $item_groups = array();
     /**
      *	Getting a data of every shop item in feed
      */
     foreach ($elements as $node) {
         foreach ($node->childNodes as $child) {
             if (trim($child->nodeValue) != '') {
                 switch ($child->nodeName) {
                     case 'ITEM_ID':
                     case 'ITEMGROUP_ID':
                     case 'PRODUCTNAME':
                     case 'PRODUCT':
                     case 'DESCRIPTION':
                     case 'MANUFACTURER':
                     case 'URL':
                     case 'PRICE_VAT':
                     case 'GIFT':
                         $data[$child->nodeName] = $child->nodeValue;
                         break;
                         /*case 'PARAM':
                           $main = $child->getElementsByTagName( 'PARAM_NAME' )->item(0)->nodeValue;
                           $value = $child->getElementsByTagName( 'VAL' )->item(0)->nodeValue;
                           $data[ $child->nodeName ][] = [ 'param' => $main, 'value' => $value ];
                           break;*/
                     /*case 'PARAM':
                       $main = $child->getElementsByTagName( 'PARAM_NAME' )->item(0)->nodeValue;
                       $value = $child->getElementsByTagName( 'VAL' )->item(0)->nodeValue;
                       $data[ $child->nodeName ][] = [ 'param' => $main, 'value' => $value ];
                       break;*/
                     case 'IMGURL':
                     case 'IMGURL_ALTERNATIVE':
                         if (count($data['IMGURLS'] < 2)) {
                             $url = $child->childNodes->item(0)->nodeValue;
                             $m = $child->nodeName == 'IMGURL' ? true : false;
                             $data['IMGURLS'][] = ['url' => $url, 'main' => $m];
                         }
                         break;
                     case 'CATEGORYTEXT':
                         $data['CATEGORYTEXT'] = Section::parse(str_replace('Heureka.cz | ', '', $child->nodeValue));
                         break;
                     default:
                         continue;
                 }
             }
         }
         /**
          *  IF#1
          *  Checks if the product has variations
          */
         if (isset($data['ITEMGROUP_ID'])) {
             /**
              *  IF#2
              *  Checks if it is the very first occurence of item group
              */
             if (isset($item_groups[$data['ITEMGROUP_ID']])) {
                 /**
                  *  IF#3
                  *  If there is already one product of this item group in DB
                  *  scripts increments number of variations it has by one.
                  */
                 if (!$item_groups[$data['ITEMGROUP_ID']]['id'] === false) {
                     $id = App\Product::where('shop_id', $data['SHOP_ID'])->where('item_id', $item_groups[$data['ITEMGROUP_ID']]['id'])->value('id');
                     App\Product::where('shop_id', $data['SHOP_ID'])->where('item_id', $item_groups[$data['ITEMGROUP_ID']]['id'])->increment('variations');
                     /**
                      *  IF#4
                      *  Saving new product picture to the DB.
                      */
                     if (isset($data['IMGURLS']) && count($data['IMGURLS']) > 0) {
                         /**
                          *  IF#5
                          *  We don't want to have multiple rows with same url in our DB
                          */
                         if (App\Image::select('id')->where('product_id', $id)->where('url', $data['IMGURLS'][0]['url'])->count() == 0) {
                             App\Image::insert(['product_id' => $id, 'url' => $data['IMGURLS'][0]['url'], 'main' => 0]);
                         }
                     }
                     /**
                      *  Since there is not a single product of this 
                      *  item group in db, we have to create one.
                      */
                 } else {
                     /**
                      *  IF#6
                      *  If there is not a single avaible image, we increment group variations.
                      */
                     if (count($data['IMGURLS']) < 1) {
                         $item_groups[$data['ITEMGROUP_ID']]['count']++;
                     } else {
                         $data['VARIATIONS'] = $item_groups[$data['ITEMGROUP_ID']]['count'];
                         $item_groups[$data['ITEMGROUP_ID']]['id'] = $data['ITEM_ID'];
                         $this->saveProduct($data);
//.........这里部分代码省略.........
开发者ID:bausano,项目名称:Ebchod,代码行数:101,代码来源:HeurekaImporter.php

示例2: getUrlByCarId

 /**
  * Get url by car id
  *
  * @param $id
  * @return Url
  */
 public function getUrlByCarId($id)
 {
     return Image::select('url')->where('car_id', $id)->first();
 }
开发者ID:leonlianght,项目名称:AlwaysRejoice,代码行数:10,代码来源:ReferenceRepository.php


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