当前位置: 首页>>代码示例>>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;未经允许,请勿转载。