Example #1
0
 /**
  * Makes an encoded list of strings from an array
  * @param array $a Containing the data
  * @param int $mode Constant
  *      - LIST_COMMA:          comma separated, no field names
  *      - LIST_AND:            ANDed WHERE clause (without the WHERE). See
  *        the documentation for $conds in DatabaseBase::select().
  *      - LIST_OR:             ORed WHERE clause (without the WHERE)
  *      - LIST_SET:            comma separated with field names, like a SET clause
  *      - LIST_NAMES:          comma separated field names
  * @param array $binaryColumns Contains a list of column names that are binary types
  *      This is a custom parameter only present for MS SQL.
  *
  * @throws MWException|DBUnexpectedError
  * @return string
  */
 public function makeList($a, $mode = LIST_COMMA, $binaryColumns = array())
 {
     if (!is_array($a)) {
         throw new DBUnexpectedError($this, 'DatabaseBase::makeList called with incorrect parameters');
     }
     if ($mode != LIST_NAMES) {
         // In MS SQL, values need to be specially encoded when they are
         // inserted into binary fields. Perform this necessary encoding
         // for the specified set of columns.
         foreach (array_keys($a) as $field) {
             if (!isset($binaryColumns[$field])) {
                 continue;
             }
             if (is_array($a[$field])) {
                 foreach ($a[$field] as &$v) {
                     $v = new MssqlBlob($v);
                 }
                 unset($v);
             } else {
                 $a[$field] = new MssqlBlob($a[$field]);
             }
         }
     }
     return parent::makeList($a, $mode);
 }