From 2c5828c320cc7a3dfd47559dfe1dd1bde76c1b10 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 18 Jan 2018 17:15:59 -0500 Subject: [PATCH] add id list formatter for db_printf --- db.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/db.php b/db.php index d24d8b6..fcf5328 100644 --- a/db.php +++ b/db.php @@ -111,6 +111,7 @@ function db_send_query($sql) { # # %% put a % in the output # %i put an integer in the output (strips non-numeric digits, and puts in 0 if blank) +# %I a list of integers (as %i) separated by commas # %f put a floating point value in the output (strips non-numeric digits, puts in 0.0 if not valid) # %" output double quotes, surrounding the variable which is encoded to be in there. # %s output encoded to be in double quotes, but don't output the quotes @@ -147,9 +148,18 @@ function _db_printf($str, $args) { } elseif($chr == 's') { $out .= db_enc_sql(array_shift($args)); } elseif($chr == 'i') { - $int = format_int(array_shift($args)); - if($int == '') $int = '0'; - $out .= $int; + $out .= format_int_0(array_shift($args)); + } elseif($chr == 'I') { + $arg = array_shift($args); + $first = true; + foreach ($arg as $int) { + if ($first) { + $first = false; + } else { + $out .= ','; + } + $out .= format_int_0($int); + } } elseif($chr == 'f') { $arg = array_shift($args); if(is_numeric($arg)) { -- 1.7.10.4