本文整理匯總了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);
}
示例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;
}
示例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);
}
}