Skip to content

Commit 1927990

Browse files
committed
added DB::get_query
1 parent 812f76a commit 1927990

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/DB.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,28 @@ public function on_error($error_callback) {
330330
}
331331
}
332332

333+
public function get_query() {
334+
$info = $this->get_info();
335+
$query = $info['statement'];
336+
337+
if (!empty($info['bind'])) {
338+
foreach ($info['bind'] as $field => $value) {
339+
$query = str_replace(':'.$field, $this->quote($value), $query);
340+
}
341+
}
342+
343+
return $query;
344+
}
345+
333346
public function get_info() {
334347
$info = [];
335348

336349
if (!empty($this->_sql)) {
337-
$info['SQL'] = $this->_sql;
350+
$info['statement'] = $this->_sql;
338351
}
339352

340353
if (!empty($this->_bind)) {
341-
$info['Bind'] = $this->_bind;
354+
$info['bind'] = $this->_bind;
342355
}
343356

344357
return $info;
@@ -494,4 +507,4 @@ private function cleanup($bind = '') {
494507

495508
return $bind;
496509
}
497-
}
510+
}

0 commit comments

Comments
 (0)