mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-24028 cast all bools in DML params to integers 1/0; credit goes to Eloy Lafuente
This commit is contained in:
parent
deb73728e7
commit
0e6e90516a
2 changed files with 30 additions and 0 deletions
|
@ -632,6 +632,11 @@ abstract class moodle_database {
|
|||
// convert table names
|
||||
$sql = $this->fix_table_names($sql);
|
||||
|
||||
// cast booleans to 1/0 int
|
||||
foreach ($params as $key => $value) {
|
||||
$params[$key] = is_bool($value) ? (int)$value : $value;
|
||||
}
|
||||
|
||||
// NICOLAS C: Fixed regexp for negative backwards lookahead of double colons. Thanks for Sam Marshall's help
|
||||
$named_count = preg_match_all('/(?<!:):[a-z][a-z0-9_]*/', $sql, $named_matches); // :: used in pgsql casts
|
||||
$dollar_count = preg_match_all('/\$[1-9][0-9]*/', $sql, $dollar_matches);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue