eee
This commit is contained in:
+22
-2
@@ -88,9 +88,29 @@ class Command extends Component
|
||||
* @return mixed
|
||||
* @throws
|
||||
*/
|
||||
public function rowCount(): int
|
||||
public function rowCount(): mixed
|
||||
{
|
||||
return $this->search('rowCount');
|
||||
$client = $this->connection->getConnection();
|
||||
try {
|
||||
if (($prepare = $client->query($this->sql)) === false) {
|
||||
throw new Exception('(' . $prepare->errorInfo()[0] . ')' . $client->errorInfo()[2]);
|
||||
}
|
||||
|
||||
$prepare->execute($this->params);
|
||||
$prepare->closeCursor();
|
||||
|
||||
$this->connection->println($this->sql, $this->params);
|
||||
|
||||
return $prepare->rowCount();
|
||||
} catch (Throwable $throwable) {
|
||||
if ($this->isRefresh($throwable)) return $this->rowCount();
|
||||
|
||||
$errorMsg = $throwable->getMessage() . PHP_EOL . ' Sql: ' . $this->sql . '.' . json_encode($this->params);
|
||||
$this->getLogger()->failure($errorMsg . PHP_EOL, 'mysql');
|
||||
return 0;
|
||||
} finally {
|
||||
$this->connection->release($client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user