PHP Fatal error: Uncaught MongoDB\\Driver\\Exception\\RuntimeException: Invalid reply to find command. in .../library/MongoDB/Operation/Find.php:299
Stack trace:
#0 .../library/MongoDB/Operation/Find.php(299): MongoDB\\Driver\\Server->executeQuery('crm.t_accountin...', Object(MongoDB\\Driver\\Query), Array)
#1 .../library/MongoDB/Operation/FindOne.php(126): MongoDB\\Operation\\Find->execute(Object(MongoDB\\Driver\\Server))
#2 .../library/MongoDB/Collection.php(657): MongoDB\\Operation\\FindOne->execute(Object(MongoDB\\Driver\\Server))
#3 .../Mongo.php(211): MongoDB\\Collection->findOne(Array, Array)
#4 xxx.php(315): xxx->fetchRow('xxx...', Array, 'xxx...')
#5 xxx.php(220): xxx->fetchR in xxx/library/MongoDB/Operation/Find.php on line 299
网上有些说这个问题在 1.2 版本中已经修复了:
PHPC-625
mongodb/mongo-php-driver#174
mongodb/mongo-php-driver#527
语法是根据 php-library findOne文档 来的
自己操作类中的 fetchRow
,其中私有函数都是些简单的转换:
/**
* 返回一行数据
*
* @param string $collectionName 集合名
* @param array $condition 条件
* @param string|null $fields 字段
* @return array|bool
*/
public function fetchRow($collectionName, $condition = [], $fields = null) {
$options = [];
if (! empty($fields)) {
$options['projection'] = $this->_toFieldsArray($fields);
}
$result = $this->getConnection()
->selectCollection($this->database, $collectionName)
->findOne($condition, $options);
$result = $this->_toArray($result);
return $this->_checkCharset($result, false);
}
呼唤远方