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


PHP Resources::fetchAll方法代碼示例

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


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

示例1: listAction

 function listAction()
 {
     $this->view->title = 'Template Resource List';
     $template_id = $this->_request->getParam('template_id');
     $this->view->template_id = $template_id;
     $resource_class = new Resources();
     $resources = $resource_class->fetchAll($resource_class->select());
     $this->view->form = new ResourceForm(array('template_id' => $template_id));
     $this->view->form->submit->setLabel('Upload');
     if ($this->_request->isPost()) {
         $form_data = $this->_request->getPost();
         if ($this->view->form->isValid($form_data)) {
             $resource_class = new Resources();
             // look at each template resource to see if it was uploaded
             $resources = $resource_class->fetchAll($resource_class->select()->where('template_id = ?', $template_id));
             foreach ($resources as $resource) {
                 $field = 'resource_' . $resource->id;
                 if (is_uploaded_file($_FILES[$field]['tmp_name'])) {
                     $resource->data = join('', file($_FILES[$field]['tmp_name']));
                     $resource->file_type = $_FILES[$field]['type'];
                     $resource->save();
                 }
             }
             $this->_redirect('/resource/list/template_id/' . $template_id);
         } else {
             $this->view->form->populate($form_data);
         }
     }
     $this->_helper->viewRenderer('form');
 }
開發者ID:ngroesz,項目名稱:Photoplate,代碼行數:30,代碼來源:ResourceController.php

示例2: getResourceFileName

 function getResourceFileName($resource)
 {
     $filename = '';
     // this regular expression matches the filename and discards the preceding path
     if (preg_match('#(\\w+/)*(\\w+\\.\\w+)#', $resource->name, $matched)) {
         $filename = $matched[2];
     } else {
         $filename = $resource->id;
     }
     // make sure that the filename is unique
     $resource_class = new Resources();
     $resources = $resource_class->fetchAll('template_id=' . $this->template_id);
     $unique = 1;
     do {
         foreach ($resources as $other_resource) {
             if ($resource->id != $other_resource->id && array_key_exists($other_resource->id, $this->resource_id_to_filename) && strcmp($filename, $this->resource_id_to_filename[$other_resource->id]) == 0) {
                 $unique = 0;
                 $filename = $resource->id . '_' . $filename;
             }
         }
     } while ($unique == 0);
     return $filename;
 }
開發者ID:ngroesz,項目名稱:Photoplate,代碼行數:23,代碼來源:ViewerBuilder.php

示例3: resourcesToDb

 function resourcesToDb($resources, $template_id)
 {
     $resource_class = new Resources();
     foreach ($resources as $resource) {
         $select = $resource_class->select()->where('name = ?', $resource)->where('template_id = ?', $template_id);
         $existing_resource = $resource_class->fetchAll($select);
         if (sizeof($existing_resource) == 0) {
             $row = $resource_class->createRow();
             $row->name = $resource;
             $row->template_id = $template_id;
             $row->save();
         }
     }
 }
開發者ID:ngroesz,項目名稱:Photoplate,代碼行數:14,代碼來源:TemplateController.php


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