Skip to content

Commit 34fc647

Browse files
authored
Optimized the code for pgsql.
1 parent 6db12a5 commit 34fc647

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/PostgreSqlSwooleExtConnection.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,21 @@ public function queryAll(string $query, array $bindings = []): array
151151
throw new QueryException($query, [], new Exception($statement->error));
152152
}
153153

154-
return $statement->fetchAll(SW_PGSQL_ASSOC);
154+
return $statement->fetchAll();
155155
}
156156

157-
public function str_replace_once($needle, $replace, $haystack)
157+
/**
158+
* @param string $needle
159+
* @param string $replace
160+
* @param string $haystack
161+
* @deprecated ,using `strReplaceOnce` instead
162+
*/
163+
public function str_replace_once($needle, $replace, $haystack): array|string
164+
{
165+
return $this->strReplaceOnce($needle, $replace, $haystack);
166+
}
167+
168+
public function strReplaceOnce(string $needle, string $replace, string $haystack): array|string
158169
{
159170
// Looks for the first occurence of $needle in $haystack
160171
// and replaces it with $replace.
@@ -219,7 +230,7 @@ protected function prepare(string $query, bool $useReadPdo = true): PostgreSQLSt
219230
{
220231
$num = 1;
221232
while (strpos($query, '?')) {
222-
$query = $this->str_replace_once('?', '$' . $num++, $query);
233+
$query = $this->strReplaceOnce('?', '$' . $num++, $query);
223234
}
224235

225236
/** @var PostgreSQL $pdo */

0 commit comments

Comments
 (0)