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 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档