dongzun9958 2015-10-14 23:30
浏览 255
已采纳

云代码中的Parse.com php-sdk错误:'DateTime :: __ construct()需要字符串,给定数组'

I am calling this function in cloud code (it's a pretty simple search function to get around the fact that the php sdk has no "contains") :

Parse.Cloud.define("searchVenues", function(request,response) {
 var query = new Parse.Query("Venue");
 query.contains("nameLowercase",request.params.term);
 query.find({
  success: function(results){
   response.success(results);
  },error: function(){
   response.error("Cloud Venue search failed");
  }
 });
});

I am calling it in a php script as follows:

$search_result = ParseCloud::run("searchVenues", ["term" => $term]);

This function used to work! But now I am getting an error and the following stack trace:

:  Uncaught exception 'Exception' with message 'DateTime::__construct()     expects parameter 1 to be string, array given' in        C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseObject.php:683
Stack trace:
#0 C:\xampp\htdocs\bcweb\vendor\parse\php- sdk\src\Parse\ParseObject.php(683): DateTime->__construct(Array)
#1 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseObject.php(631): Parse\ParseObject->_mergeMagicFields(Array)
#2 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseObject.php(599): Parse\ParseObject->mergeFromServer(Array, true)
#3 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseClient.php(198): Parse\ParseObject->_mergeAfterFetch(Array)
#4 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseClient.php(209): Parse\ParseClient::_decode(Array)
#5 C:\xampp\htdocs\bcweb\vendor\parse\php-sdk\src\Parse\ParseCloud.php(35): Parse\ParseClient::_decode(Array)
#6 C:\xampp\htdocs\bcweb\lrs\makeCrawl.php(21): Parse\ParseCloud::run('searchVenues', Array)
#7 {main}

I can't imagine what happened to break this? I have a companion function that creates the nameLowercase field on new records, as well. This was there during the happy times when the function worked correctly, so I can't imagine it's existence has anything to do with the error:

Parse.Cloud.beforeSave("Venue", function(request, response) {
 if (request.object.get("name")) {
     request.object.set("nameLowercase",request.object.get("name").toLowerCase());
 }
 response.success();
});

There are some single quotes in the strings, but they were there before too. Can anyone who has knowledge of the parse php-sdk explain what may be the problem here? Thanks!

  • 写回答

1条回答 默认 最新

  • doudieyou5209 2015-12-14 01:33
    关注

    The error was in the parse php-sdk. Updating the php-sdk to version 1.1.9 fixed this problem, and the code works as it did before.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题