本文整理汇总了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);
}
}