當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。