简体   繁体   English

Parse.com PHP SDK-刷新用户数据-提取命令

[英]Parse.com PHP SDK - Refresh user data - Fetch command

I'm using the Parse.com PHP SDK on one of my pages. 我在其中一页上使用Parse.com PHP SDK。 I seem to have a similar problem I faced on the iOS version but I easily solved that using the 'fetch' command. 我似乎在iOS版本上也遇到过类似的问题,但是我可以使用'fetch'命令轻松解决该问题。

The problem is when I edit information in my database, it does not update on my web page when I refresh the page. 问题是当我编辑数据库中的信息时,刷新页面时它不会在我的网页上更新。 The user has to log out then log back in for the new data to be shown. 用户必须注销然后重新登录才能显示新数据。

Here is how I'm getting the data: 这是我获取数据的方式:

<?php $u1=ParseUser::getCurrentUser()->get("auto"); echo $u1; ?>

Here is the documentation on the 'fetch' command but I don't understand how it works or how it is implemented: http://parseplatform.org/parse-php-sdk/classes/Parse.ParseUser.html#method_fetch 这是有关“获取”命令的文档,但我不了解它的工作方式或实现方式: http : //parseplatform.org/parse-php-sdk/classes/Parse.ParseUser.html#method_fetch

Does anyone know how to show the updated string values using this command or anything similar that would work? 有谁知道如何使用此命令或类似的方法显示更新的字符串值?

The issue you're seeing is a cached object in your current session, specifically the current ParseUser . 您看到的问题是当前会话中的缓存对象 ,特别是当前ParseUser You can see that the php sdk attempts to find the current user from a variety of places, all effectively independent of the server-side copy. 您可以看到php sdk尝试从多个位置查找当前用户 ,而这些位置实际上都独立于服务器端副本。

You were in the right direction, you can use the fetch method to 'refresh' any ParseObject by updating it with any new changes from the database: 您的方向是正确的,您可以使用fetch方法通过用数据库中的任何新更改来更新任何ParseObject来“刷新”任何ParseObject

// get the current user
$user = ParseUser::getCurrentUser();

// fetch changes from parse
$user->fetch();

// get your newly set key/value pair
$isAuto = $user->get('auto');

Your user object will then be refreshed with the changes you need. 然后,您的用户对象将随需要的更改而刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM