Skip to content

Commit 107c337

Browse files
committed
Merge pull request #65 from alpha0010/master
Improve quoting performance
2 parents 950d344 + f2d8d75 commit 107c337

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Drivers/Mysqli/Connection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ public function multiQuery(Array $queue)
251251
*/
252252
public function escape($value)
253253
{
254-
$this->ping();
254+
if ($this->connection === null) {
255+
// this function is called a lot, making ping a significant cost if called every time
256+
$this->ping();
257+
}
255258

256259
if (($value = $this->getConnection()->real_escape_string((string) $value)) === false) {
257260
// @codeCoverageIgnoreStart

src/Helper.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,11 @@ public function callSnippets($data, $index, $query, $options = array())
203203
array_unshift($options, $data, $index, $query);
204204

205205
$arr = $this->getConnection()->quoteArr($options);
206-
array_walk(
207-
$arr,
208-
function (&$val, $key) {
209-
if (is_string($key)) {
210-
$val = $val.' AS '.$key;
211-
}
206+
foreach ($arr as $key => &$val) {
207+
if (is_string($key)) {
208+
$val .= ' AS '.$key;
212209
}
213-
);
210+
}
214211

215212
return $this->query('CALL SNIPPETS('.implode(', ', $arr).')');
216213
}

0 commit comments

Comments
 (0)