當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Images::addImage方法代碼示例

本文整理匯總了PHP中Images::addImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Images::addImage方法的具體用法?PHP Images::addImage怎麽用?PHP Images::addImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Images的用法示例。


在下文中一共展示了Images::addImage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionConvert

 public function actionConvert()
 {
     @set_time_limit(0);
     @ini_set('max_execution_time', 0);
     $sql = 'SELECT id, owner_id FROM {{apartment}} WHERE 1';
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     $ids = CHtml::listData($res, 'id', 'owner_id');
     $sql = 'SELECT pid, imgsOrder FROM {{galleries}} WHERE 1';
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     if ($res) {
         foreach ($res as $item) {
             $images = unserialize($item['imgsOrder']);
             if (!isset($ids[$item['pid']])) {
                 continue;
             }
             if ($images) {
                 $cnt = 0;
                 foreach ($images as $image => $name) {
                     $filePath = Yii::getPathOfAlias('webroot.uploads.apartments.' . $item['pid'] . '.pictures') . '/' . $image;
                     Images::addImage($filePath, $item['pid'], $cnt == 0, $ids[$item['pid']]);
                     $cnt++;
                 }
             }
         }
     }
 }
開發者ID:alexjkitty,項目名稱:estate,代碼行數:26,代碼來源:MainController.php

示例2: actionConvert

 public function actionConvert()
 {
     @set_time_limit(0);
     @ini_set('max_execution_time', 0);
     @ini_set('gd.jpeg_ignore_warning', 1);
     $limit = 200;
     $data = Yii::app()->statePersister->load();
     $lastImportId = isset($data['last_import_id']) ? $data['last_import_id'] : 0;
     $sql = 'SELECT id, owner_id FROM {{apartment}} WHERE id > ' . $lastImportId . ' LIMIT ' . $limit;
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     $ids = CHtml::listData($res, 'id', 'owner_id');
     $sql = 'SELECT pid, imgsOrder FROM {{galleries}} WHERE pid > ' . $lastImportId . ' LIMIT ' . $limit;
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     $i = 0;
     if ($res) {
         foreach ($res as $item) {
             $images = unserialize($item['imgsOrder']);
             if (!isset($ids[$item['pid']])) {
                 continue;
             }
             if ($images) {
                 $cnt = 0;
                 foreach ($images as $image => $name) {
                     $filePath = Yii::getPathOfAlias('webroot.uploads.apartments.' . $item['pid'] . '.pictures') . '/' . $image;
                     try {
                         Images::addImage($filePath, $item['pid'], $cnt == 0, $ids[$item['pid']]);
                     } catch (Exception $e) {
                         echo '<b>Выброшено исключение: ', $e->getMessage(), "\n</b><br>";
                     }
                     $cnt++;
                 }
             }
             $data['last_import_id'] = $item['pid'];
             Yii::app()->statePersister->save($data);
             $i++;
             if ($i >= $limit) {
                 break;
             }
         }
     }
     echo 'Converted ' . $i . ' ads';
 }
開發者ID:barricade86,項目名稱:raui,代碼行數:42,代碼來源:MainController.php


注:本文中的Images::addImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。