diff --git a/application/Core/Helper.php b/application/Core/Helper.php
new file mode 100644
index 0000000..01eb396
--- /dev/null
+++ b/application/Core/Helper.php
@@ -0,0 +1,57 @@
+ $value) {
+
+ // check if named parameters (':param') or anonymous parameters ('?') are used
+ if (is_string($key)) {
+ $keys[] = '/' . $key . '/';
+ } else {
+ $keys[] = '/[?]/';
+ }
+
+ // bring parameter into human-readable format
+ if (is_string($value)) {
+ $values[$key] = "'" . $value . "'";
+ } elseif (is_array($value)) {
+ $values[$key] = implode(',', $value);
+ } elseif (is_null($value)) {
+ $values[$key] = 'NULL';
+ }
+ }
+
+ /*
+ echo "
[DEBUG] Keys:
"; + print_r($keys); + + echo "\n[DEBUG] Values: "; + print_r($values); + echo ""; + */ + + $raw_sql = preg_replace($keys, $values, $raw_sql, 1, $count); + + return $raw_sql; + } + +} diff --git a/application/Model/Song.php b/application/Model/Song.php index 1750116..9a49750 100644 --- a/application/Model/Song.php +++ b/application/Model/Song.php @@ -50,7 +50,7 @@ public function addSong($artist, $track, $link) $parameters = array(':artist' => $artist, ':track' => $track, ':link' => $link); // useful for debugging: you can see the SQL behind above construction by using: - // echo '[ PDO DEBUG ]: ' . Helper::debugPDO($sql, $parameters); exit(); + // echo '[ PDO DEBUG ]: ' . \Mini\Core\Helper::debugPDO($sql, $parameters); exit(); $query->execute($parameters); }