public static function fetchAll($where = null, $order = null, $limit = null, $offset = null)
 {
     $resultSet = self::getDbTable()->fetchAll($where, $order, $limit, $offset);
     $entries = array();
     foreach ($resultSet as $row) {
         $entry = new Application_Model_O_DepartmentsAdditional();
         $entry->setId($row->id)->setDepartment_id($row->department_id)->setTitle($row->title)->setContent($row->content)->setImg($row->img)->setSort($row->sort)->setType($row->type)->setCtime($row->ctime)->setUtime($row->utime)->setStatus($row->status);
         $entry->setNew(false);
         $entries[] = $entry;
     }
     return $entries;
 }
Exemplo n.º 2
0
 public function addiasyncajaxAction()
 {
     $this->getResponse()->setHeader('Content-Type', 'application/json');
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $params = $this->_getAllParams();
     $hmsg = $this->_getParam('hmsg');
     //    	echo "<pre>";var_dump($params);exit;
     $addi = new Application_Model_O_DepartmentsAdditional();
     $validate = new Yy_Validate_Value();
     if ($validate->isValid($params['id'])) {
         $addi->setId($params['id']);
     } else {
         $addi->setCtime(date('Y-m-d H:i:s'));
     }
     if ($validate->isValid($params['did'])) {
         $addi->setDepartment_id($params['did']);
     }
     if ($validate->isValid($params['title'])) {
         $addi->setTitle($params['title']);
     }
     if ($validate->isValid($params['content'])) {
         $addi->setContent($params['content']);
     }
     if ($validate->isValid($params['sort'])) {
         $addi->setSort($params['sort']);
     }
     if ($validate->isValid($params['type'])) {
         $addi->setType($params['type']);
     }
     if ($validate->isValid($params['status'])) {
         $addi->setStatus($params['status']);
     }
     try {
         $addi->save();
         $id = $addi->getId();
         //保存热门项目附件信息图片
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $wrdir = Yy_Utils::getWriteDir();
         $adapter->setDestination($wrdir);
         if (!$adapter->receive()) {
             $messages = $adapter->getMessages();
             //echo implode("\n", $messages);
         }
         $filename = $adapter->getFileName();
         if (is_string($filename)) {
             $handle = fopen($filename, 'rb');
             $img = addslashes(fread($handle, filesize($filename)));
             fclose($handle);
             Application_Model_M_DepartmentsAdditional::updateImage($id, $img);
         }
         $url = '/costperf/addiview?id=' . $id . '&from=add&did=' . $params['did'] . '&hmsg=' . $hmsg;
         $this->redirect($url);
     } catch (Zend_Db_Exception $e) {
         $this->redirect('/error?message=' . $e->getMessage());
     }
 }