XDB::escaped use XDB::formatArray format to format array arguments.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 6 Mar 2010 18:20:41 +0000 (19:20 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 6 Mar 2010 18:20:41 +0000 (19:20 +0100)
What does this mean?
 XDB::format('blah in {?}', $array);
is now the same as previous notation:
 'blah in ' . XDB::formatArray($array);

WARNING: this might breaks some pieces of code where previous
serialisation of arrays was used.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/xdb.php

index 2a2efae..1776791 100644 (file)
@@ -159,7 +159,7 @@ class XDB
     // Produce the SQL statement representing an array
     public static function formatArray(array $array)
     {
-        return '(' . implode(', ', array_map(array('XDB', 'escape'), $array)) . ')';
+        return self::escape($array);
     }
 
     const WILDCARD_EXACT    = 0x00;
@@ -317,9 +317,12 @@ class XDB
           case 'object':
             if ($var instanceof PlFlagSet) {
                 return "'" . addslashes($var->flags()) . "'";
+            } else {
+                return "'".addslashes(serialize($var))."'";
             }
+
           case 'array':
-            return "'".addslashes(serialize($var))."'";
+            return '(' . implode(', ', array_map(array('XDB', 'escape'), $var)) . ')';
 
           default:
             die(var_export($var, true).' is not a valid for a database entry');