diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-04-18 19:54:17 -0400 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-04-18 19:54:17 -0400 |
commit | 0d9c5c1ccd66018a819b4ca327ab203f473e35dc (patch) | |
tree | f55e5caa8bf8036b02fc553eecd2b615791d2ce5 /engine/lib/database.php | |
parent | ca63a6b81eee1dfbee99a393a790402475a4612c (diff) | |
parent | d928588805375e7190ab393e2def555b39701a27 (diff) | |
download | elgg-0d9c5c1ccd66018a819b4ca327ab203f473e35dc.tar.gz elgg-0d9c5c1ccd66018a819b4ca327ab203f473e35dc.tar.bz2 |
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r-- | engine/lib/database.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php index a9c4017a0..6b1b494b9 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -680,22 +680,31 @@ function sanitize_string($string) { * Sanitises an integer for database use. * * @param int $int Integer - * + * @param bool[optional] $signed Whether negative values should be allowed (true) * @return int Sanitised integer */ -function sanitise_int($int) { +function sanitise_int($int, $signed = true) { + $int = (int) $int; + + if ($signed === false) { + if ($int < 0) { + $int = 0; + } + } + return (int) $int; } /** - * Wrapper function for alternate English spelling + * Sanitises an integer for database use. + * Wrapper function for alternate English spelling (@see sanitise_int) * * @param int $int Integer - * + * @param bool[optional] $signed Whether negative values should be allowed (true) * @return int Sanitised integer */ -function sanitize_int($int) { - return (int) $int; +function sanitize_int($int, $signed = true) { + return sanitise_int($int, $signed); } /** |