swoole ide

This commit is contained in:
zyimm 2022-10-23 14:57:03 +08:00
parent 5426ffaf38
commit 27f46b9671
2 changed files with 5 additions and 8 deletions

View File

@ -29,6 +29,7 @@
} }
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5" "phpunit/phpunit": "^9.5",
"swoole/ide-helper": "~5.0.0"
} }
} }

View File

@ -47,15 +47,12 @@ class MongodbConnection extends Connection implements ConnectionInterface
/** /**
* Reconnect the connection. * Reconnect the connection.
* *
* @see http://php.net/manual/zh/mongodb-driver-manager.construct.php
* @throws MongoDBException * @throws MongoDBException
*/ */
public function reconnect(): bool public function reconnect(): bool
{ {
try { try {
/**
* http://php.net/manual/zh/mongodb-driver-manager.construct.php
*/
$username = $this->config['username']; $username = $this->config['username'];
$password = $this->config['password']; $password = $this->config['password'];
if (!empty($username) && !empty($password)) { if (!empty($username) && !empty($password)) {
@ -249,8 +246,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
array $options = [] array $options = []
): array { ): array {
// 查询数据 // 查询数据
$data = []; $data = $result = [];
$result = [];
//每次最多返回10条记录 //每次最多返回10条记录
if (!isset($options['limit']) || (int) $options['limit'] <= 0) { if (!isset($options['limit']) || (int) $options['limit'] <= 0) {
$options['limit'] = $limit; $options['limit'] = $limit;
@ -294,7 +290,7 @@ class MongodbConnection extends Connection implements ConnectionInterface
try { try {
$command = new Command([ $command = new Command([
'count' => $namespace, 'count' => $namespace,
'query' => empty($filter) ? (object)[]:$filter 'query' => empty($filter) ? (object) [] : $filter
]); ]);
$cursor = $this->connection->executeCommand($this->config['db'], $command); $cursor = $this->connection->executeCommand($this->config['db'], $command);
return $cursor->toArray()[0]->n; return $cursor->toArray()[0]->n;