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


PHP Report::toArray方法代码示例

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


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

示例1: getReports

function getReports($filter)
{
    $reports = array();
    if (!is_null($filter)) {
        $db = new Database();
        $sql = "SELECT `id` FROM reports WHERE statusID=?";
        $sql = $db->prepareQuery($sql, $filter);
    } else {
        //not filtered. all reports
        $db = new Database();
        $sql = "SELECT `id` FROM reports";
    }
    $results = $db->select($sql);
    if (is_array($results)) {
        foreach ($results as $result) {
            $newReport = new Report();
            $newReport->fetch($result['id']);
            $reports[] = $newReport->toArray();
        }
    }
    return $reports;
}
开发者ID:JakeDawkins,项目名称:NiceCatch,代码行数:22,代码来源:Funcs.php

示例2: toArray

 public function toArray()
 {
     return ['timestamp' => $this->timestamp->format(\DateTime::ATOM)] + $this->report->toArray();
 }
开发者ID:mfn,项目名称:php-analyzer,代码行数:4,代码来源:TimestampedReport.php

示例3: reportPhotoPost

 private function reportPhotoPost()
 {
     if (!$this->validatePhoto()) {
         return 'error: photo upload failed';
     }
     $report = new Report();
     //fetch and check for valid report
     $report->fetch($this->args[0]);
     if ($report->getID() == null) {
         $this->response['message'] = 'error: failed to load report with id ' . $this->args[0];
         $this->response['code'] = 405;
     }
     //report id
     $reportID = $this->args[0];
     $photo = $this->files['photo'];
     $upload_dir = Path::uploads() . $reportID . '/';
     //make the directory if it doesn't already exist
     if (!file_exists($upload_dir)) {
         mkdir($upload_dir, 0755, true);
     }
     //make sure there wasnt an error with the upload
     if ($photo['error'] !== UPLOAD_ERR_OK) {
         $this->response['message'] = 'error: photo upload error';
         $this->response['code'] = 400;
     }
     //make sure filename is safe
     $name = preg_replace("/[^A-Z0-9._-]/i", "_", $photo['name']);
     //different dir for each report
     $i = 0;
     $parts = pathinfo($name);
     while (file_exists($upload_dir . $name)) {
         //myfile-1.png
         $name = $parts['filename'] . '-' . $i . '.' . $parts['extension'];
     }
     //move file from temp directory
     $success = move_uploaded_file($photo['tmp_name'], $upload_dir . $name);
     if (!$success) {
         $this->response['message'] = 'error: unable to save file';
         $this->response['code'] = 500;
     }
     //set proper file permissions on new file
     chmod($upload_dir . $name, 0644);
     //update the report in DB with file location
     $report->setPhotoPath($upload_dir . $name);
     $report->save();
     return $report->toArray();
 }
开发者ID:JakeDawkins,项目名称:NiceCatch,代码行数:47,代码来源:class.NiceCatchAPI.php


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