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


PHP Posts::hydrate方法代碼示例

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


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

示例1: getGabById

 public function getGabById($idGab, $bdd)
 {
     $liste = array();
     $i = 0;
     $listePosts = $bdd->query('SELECT * FROM posts WHERE (id=' . $idGab . ') ORDER BY id DESC');
     while ($item = $listePosts->fetch()) {
         $post = new Posts();
         $post->hydrate($item['id'], $item['id_user'], $item['text'], $item['id_post_origin'], $item['likes'], $bdd);
         $liste[$i] = $post;
         $i++;
     }
     $this->setListePosts($liste);
 }
開發者ID:sewelseb,項目名稱:gabbler,代碼行數:13,代碼來源:ListePosts.class.php

示例2: _save

 /**
  * Save post
  *
  * @param \Posts $post
  * @param $error
  * @return bool
  */
 protected function _save(\Posts &$post, &$error)
 {
     $isDraft = $post->getIsDraft();
     $input = $this->request()->post('post', 'ARRAY', array());
     $post->hydrate($input);
     $post->setExcerpt(nl2br($post->getExcerpt()));
     $post->setIsDraft(false);
     $error = Plugin::applyFilters('verify_' . $post->getTaxonomy() . '_form_data', $error);
     if (!$post->getAuthor()) {
         $post->setAuthor($this->getSessionUser()->getName());
     }
     if (!$post->isDraft() && !($post->getPublishTime() || $post->getPublishTime()->isEmpty())) {
         $post->setPublishTime(new DateTime());
     }
     if (empty($error) && $post->save()) {
         $post = Plugin::applyFilters('handling_' . $post->getTaxonomy() . '_form_data', $post);
         if ($isDraft) {
             $this->dispatch('after_publish_' . $post->getTaxonomy() . '_post', new CMSBackendEvent($this, array('post' => $post)));
         } else {
             $this->dispatch('after_save_' . $post->getTaxonomy() . '_post', new CMSBackendEvent($this, array('post' => $post)));
         }
         return true;
     } else {
         foreach ($post->getValidationFailures() as $validationFailure) {
             $error[$validationFailure->getColumn()] = $validationFailure->getMessage();
         }
     }
     return false;
 }
開發者ID:hosivan90,項目名稱:toxotes,代碼行數:36,代碼來源:Post.php

示例3: getAllMyGabs

 public function getAllMyGabs($bdd)
 {
     $i = 0;
     $listeGabs = new ListePosts();
     $mesPosts = array();
     $listePosts = $bdd->query('SELECT * FROM posts WHERE (id_user=' . $this->getId() . ') ORDER BY id DESC');
     while ($item = $listePosts->fetch()) {
         $post = new Posts();
         $post->hydrate($item['id'], $item['id_user'], $item['text'], $item['id_post_origin'], $item['likes'], $bdd);
         $mesPosts[$i] = $post;
         $i++;
     }
     $listeGabs->setListePosts($mesPosts);
     if (isset($mesPosts)) {
         $this->setMesGabs($listeGabs);
     }
 }
開發者ID:sewelseb,項目名稱:gabbler,代碼行數:17,代碼來源:Users.class.php


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