本文整理汇总了PHP中Post::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::getId方法的具体用法?PHP Post::getId怎么用?PHP Post::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_normal_post_no_inheritance
public function test_normal_post_no_inheritance()
{
$this->installAndIncludeModels(array('Post', 'Comment'));
$Post = new Post(array('title' => 'Post for unit testing', 'body' => 'This is a post for testing the model'));
$Post->comment->create(array('body' => 'hello', 'name' => 'Aditya'));
$Post->save();
$Post->reload();
$expected_id = $Post->getId();
$this->assertTrue($Result = $Post->find($expected_id, array('include' => array('comments'), 'conditions' => "name = 'Aditya'")));
$this->assertEqual($Result->comments[0]->get('name'), 'Aditya');
}
示例2: update
public function update(Post $post)
{
$id = $post->getId();
$content = $this->db->quote($content->getContent());
$idAuthor = $_SESSION['id'];
$query = ' UPDATE post
SET content =' . $content . ',
$idAuthor =' . $idAuthor . '
WHERE id=' . $id;
$res = $this->db->exec($query);
if ($res) {
$id = $this->db->lastInsertId();
if ($id) {
return $this->findById($id);
} else {
throw new Exception('Internal server Error');
}
}
}
示例3: save
public function save(Post $post)
{
$wp_error = null;
if ($post->getID() != null) {
wp_update_post($post->getWPPost());
} else {
$post_id = wp_insert_post($post->getWPPost(), $wp_error);
$post->setID($post_id);
}
$metas = get_metadata('post', $post->getId());
foreach ($post->getMetas() as $key => $value) {
if (isset($metas[$key]) && $metas[$key] == $value) {
continue;
}
foreach ($value as $subkey => $subvalue) {
if ($subkey == 0) {
update_post_meta($post->getID(), $key, $subvalue);
} else {
add_post_meta($post->getID(), $key, $subvalue);
}
}
}
return $this;
}
示例4: setPost
/**
* Declares an association between this object and a Post object.
*
* @param Post $v
* @return Comment The current object (for fluent API support)
* @throws PropelException
*/
public function setPost(Post $v = null)
{
if ($v === null) {
$this->setPostId(NULL);
} else {
$this->setPostId($v->getId());
}
$this->aPost = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Post object, it will not be re-added.
if ($v !== null) {
$v->addComment($this);
}
return $this;
}
示例5: delete
public function delete(Post $dto)
{
BOL_CommentService::getInstance()->deleteEntityComments('blog-post', $dto->getId());
BOL_RateService::getInstance()->deleteEntityRates($dto->getId(), 'blog-post');
BOL_TagService::getInstance()->deleteEntityTags($dto->getId(), 'blog-post');
BOL_FlagService::getInstance()->deleteByTypeAndEntityId('blog_post', $dto->getId());
OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $dto->getId())));
$this->dao->delete($dto);
}
示例6: getAllImagesWithSelect
<?php
$optionList = getAllImagesWithSelect($postOnGet->getImage());
echo $optionList;
?>
</select>
</select>
<input class="form-control" type="hidden" name="id_user" id="id_user" value="<?php
echo $userLogged->getId();
?>
">
<input class="form-control" type="hidden" name="id" id="id" <?php
echo 'value=' . $postOnGet->getId();
?>
>
<input class="form-control" type="hidden" name="action" id="action" value="edit_post">
<br>
<input type="submit" class="btn btn-primary" value="Update Post">
</form>
</div>
</div><!-- /row -->
<div class="row mt centered ">
<div class="col-lg-8 col-lg-offset-2 centered">
<h3>DELETE POST</h3>
<hr><br>
示例7: delete
/**
* Deletes specified Post object
*
* @param Post $post
* @return bool
*/
public function delete(Post $post)
{
return $this->persistence->delete($post->getId());
}
示例8: createCommentForm
/**
* Creates a form to create a Post entity.
*
* @param Post $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCommentForm(CommentFront $model, $entity)
{
$form = $this->createForm('BlogBundle\\Form\\CommentFrontType', $model, array('action' => $this->generateUrl('blog_blog_comment', array('post' => $entity->getId())), 'method' => 'POST', 'attr' => array('id' => 'comment-form', 'class' => 'comment-form')));
return $form;
}
示例9: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param Post $value A Post object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(Post $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
// if key === null
self::$instances[$key] = $obj;
}
}
示例10: delete
public function delete(Post $dto)
{
$this->deletePost($dto->getId());
}
示例11: createCommentForm
/**
* Creates a form to create a Post entity.
*
* @param Post $entity The entity
*
* @return \Symfony\Component\Form\Form The form
*/
private function createCommentForm(CommentFront $model, $entity)
{
$type = new CommentFrontType();
$form = $this->createForm($type, $model, array('action' => $this->generateUrl('core_blog_blog_comment', array('post' => $entity->getId())), 'method' => 'POST', 'attr' => array('id' => $type->getName(), 'class' => 'comment-form')));
$form->add('submit', 'submit', array('label' => 'Enviar'));
return $form;
}
示例12: delete
/**
* Deletes a Post into the database
*
* @param Post $post The post to be deleted
* @throws PDOException if a database error occurs
* @return void
*/
public function delete(Post $post)
{
$stmt = $this->db->prepare("DELETE from posts WHERE id=?");
$stmt->execute(array($post->getId()));
}
示例13: setPostData
private function setPostData(Post $post, PostsProcessor $pp)
{
$this->setExtraData('pid', $post->getId());
$this->setExtraData('rid', $post->getRubricId());
$this->setExtraData('ptype', $post->getPostType());
$this->setExtraData('pdate', $post->getDtPublication());
$this->setExtraData('pdate_dmy', $post->getDtEvent(DF_JS_DATEPICKER));
$this->setExtraData('cover', $pp->getCoverDi4Show($post->getIdent())->getRelPath());
$this->setExtraData('cover96x96', $pp->getCoverDi($post->getIdent(), '96x96')->getRelPath());
$this->setExtraData('cover156x156', $pp->getCoverDi($post->getIdent(), '156x156')->getRelPath());
$this->setExtraData('post');
//isPost
}
示例14: update
public function update(Post $post)
{
$this->updateObject('Post', 'p_id', $post->getId(), ['p_text' => $post->getText()]);
}
示例15: process
public function process($ctrl)
{
OW::getCacheManager()->clean(array(PostDao::CACHE_TAG_POST_COUNT));
$service = PostService::getInstance();
/* @var $postDao PostService */
$data = $this->getValues();
$data['title'] = UTIL_HtmlTag::stripJs($data['title']);
$postIsNotPublished = $this->post->getStatus() == 2;
$text = UTIL_HtmlTag::sanitize($data['post']);
/* @var $post Post */
$this->post->setTitle($data['title']);
$this->post->setPost($text);
$this->post->setIsDraft($_POST['command'] == 'draft');
$isCreate = empty($this->post->id);
if ($isCreate) {
$this->post->setTimestamp(time());
//Required to make #698 and #822 work together
if ($_POST['command'] == 'draft') {
$this->post->setIsDraft(2);
}
BOL_AuthorizationService::getInstance()->trackAction('blogs', 'add_blog');
} else {
//If post is not new and saved as draft, remove their item from newsfeed
if ($_POST['command'] == 'draft') {
OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'blog-post', 'entityId' => $this->post->id)));
} else {
if ($postIsNotPublished) {
// Update timestamp if post was published for the first time
$this->post->setTimestamp(time());
}
}
}
$service->save($this->post);
$tags = array();
if (intval($this->post->getId()) > 0) {
$tags = $data['tf'];
foreach ($tags as $id => $tag) {
$tags[$id] = UTIL_HtmlTag::stripTags($tag);
}
}
$tagService = BOL_TagService::getInstance();
$tagService->updateEntityTags($this->post->getId(), 'blog-post', $tags);
if ($this->post->isDraft()) {
$tagService->setEntityStatus('blog-post', $this->post->getId(), false);
if ($isCreate) {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_draft_success_msg'));
} else {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_draft_success_msg'));
}
} else {
$tagService->setEntityStatus('blog-post', $this->post->getId(), true);
//Newsfeed
$event = new OW_Event('feed.action', array('pluginKey' => 'blogs', 'entityType' => 'blog-post', 'entityId' => $this->post->getId(), 'userId' => $this->post->getAuthorId()));
OW::getEventManager()->trigger($event);
if ($isCreate) {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'create_success_msg'));
OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_ADD, array('postId' => $this->post->getId())));
} else {
OW::getFeedback()->info(OW::getLanguage()->text('blogs', 'edit_success_msg'));
OW::getEventManager()->trigger(new OW_Event(PostService::EVENT_AFTER_EDIT, array('postId' => $this->post->getId())));
}
$ctrl->redirect(OW::getRouter()->urlForRoute('post', array('id' => $this->post->getId())));
}
}