ILIAS  release_7 Revision v7.30-3-g800a261c036
inc.meta_data_converter.php
Go to the documentation of this file.
1<?php
2
3function ilMDConvert($table, $fields, $key)
4{
5 global $ilDB;
6
7 $where = "WHERE ";
8 $where .= implode(" LIKE '%\%' ESCAPE '�' OR ", ilUtil::quoteArray($fields));
9 $where .= " LIKE '%\\%' ESCAPE '�'";
10
11 $query = "SELECT * FROM " . $table . " " .
12 $where;
13
14 $res = $ilDB->query($query);
15 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
16 $query = "UPDATE $table ";
17
18 $counter = 0;
19 foreach ($fields as $field) {
20 if ($counter++) {
21 $query .= ", ";
22 } else {
23 $query .= "SET ";
24 }
25
26 $query .= ($field . " = " . $ilDB->quote(stripslashes($row->$field)) . " ");
27 }
28 $query .= (" WHERE " . $key . " = " . $ilDB->quote($row->$key));
29
30 // Perform the query
31 $ilDB->query($query);
32 }
33}
An exception for terminatinating execution or to throw for unit testing.
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
ilMDConvert($table, $fields, $key)
$query
foreach($_POST as $key=> $value) $res
global $ilDB