Skip to content

Commit d089046

Browse files
committed
Merge pull request laravel#1312 from franzliedke/patch-53
DB::escape()
2 parents 62b55ff + d7dfd4f commit d089046

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

laravel/database.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public static function raw($value)
124124
{
125125
return new Expression($value);
126126
}
127+
128+
/**
129+
* Escape a string for usage in a query.
130+
*
131+
* This uses the correct quoting mechanism for the default database connection.
132+
*
133+
* @param string $value
134+
* @return string
135+
*/
136+
public static function escape($value)
137+
{
138+
return static::connection()->pdo->quote($value);
139+
}
127140

128141
/**
129142
* Get the profiling data for all queries.

laravel/profiling/profiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static function query($sql, $bindings, $time)
145145
{
146146
foreach ($bindings as $binding)
147147
{
148-
$binding = Database::connection()->pdo->quote($binding);
148+
$binding = Database::escape($binding);
149149

150150
$sql = preg_replace('/\?/', $binding, $sql, 1);
151151
$sql = htmlspecialchars($sql);

0 commit comments

Comments
 (0)