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

云代码中的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!

图片转代码服务由CSDN问答提供 功能建议

我在云代码中调用此函数(这是一个非常简单的搜索函数来解决php sdk的事实 没有“包含”):</ p>

  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); 
},错误 :function(){
 response.error(“Cloud Venue search failed”); 
} 
}); 
}); 
 </ code> </ pre> 
 
 

I 我在PHP脚本中调用它如下:</ p>

  $ search_result = ParseCloud :: run(“searchVenues”,[“term”=&gt; $ term]); 
  </ code> </ pre> 
 
 

此功能用于工作! 但现在我收到一个错误和以下堆栈跟踪:</ p>

 :带有消息'DateTime :: __ construct()的未捕获异常'异常'需要参数1为字符串,数组 给定'在C:\ xampp \ htdocs \ bcweb \ vendor \ parse \ php-sdk \ src \ Parse \ ParseObject.php:683 
堆栈跟踪:
#0 C:\ xampp \ htdocs \ bcweb \ vendor \ parse \  php-sdk \ src \ Parse \ ParseObject.php(683):DateTime-&amp; gt; __ construct(Array)
#1 C:\ xampp \ htdocs \ bcweb \ vendor \ parse \ php-sdk \ src \ Parse \  ParseObject.php(631):Parse \ ParseObject-&amp; gt; _mergeMagicFields(Array)
#2 C:\ xampp \ htdocs \ bcweb \ vendor \ parse \ php-sdk \ src \ Parse \ ParseObject.php(599)  :Parse \ ParseObject-&amp; gt; mergeFromServer(Array,true)
#3 C:\ xampp \ htdocs \ bcweb \ vendor \ parse \ php-sdk \ src \ Parse \ ParseClient.php(198):Parse \ ParseObject  - &amp; gt; _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):Pa  rse \ ParseClient :: _ decode(Array)
#6 C:\ xampp \ htdocs \ bcweb \ lrs \ makeCrawl.php(21):Parse \ ParseCloud :: run('searchVenues',Array)
#7 {main  } 
 </ code> </ pre> 
 
 

我无法想象会发生什么破坏这个? 我有一个伴侣功能,它也会在新记录上创建nameLowercase字段。 在功能正常工作的快乐时期,这是存在的,所以我无法想象它的存在与错误有关:</ p>

  Parse.Cloud.beforeSave(“  Venue“,function(request,response){
 if(request.object.get(”name“)){
 request.object.set(”nameLowercase“,request.object.get(”name“)。toLowerCase  ()); 
} 
 response.success(); 
}); 
 </ code> </ pre> 
 
 

字符串中有一些单引号,但它们在那里 之前也是。 任何知道解析php-sdk的人都可以解释这里可能出现的问题吗? 谢谢!</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题