Functions

Services/Migration/DBUpdate_635/inc.meta_data_converter.php File Reference

Go to the source code of this file.

Functions

 ilMDConvert ($table, $fields, $key)

Function Documentation

ilMDConvert ( table,
fields,
key 
)

Definition at line 3 of file inc.meta_data_converter.php.

References $counter, $fields, $query, $res, and $row.

{
        global $ilDB;

        $where = "WHERE ";
        $where .= (implode(" LIKE '%\%' ESCAPE '' OR ",$fields));
        $where .= " LIKE '%\\%' ESCAPE ''";

        $query = "SELECT * FROM $table ".
                $where;

        $res = $ilDB->query($query);
        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
        {
                $query = "UPDATE $table ";

                $counter = 0;
                foreach($fields as $field)
                {
                        if($counter++)
                                $query .= ", ";
                        else
                                $query .= "SET ";

                        $query .= ($field ." = '".addslashes(stripslashes($row->$field))."'");
                }
                $query .= (" WHERE $key = ".$row->$key);

                // Perform the query
                $ilDB->query($query);
        }
}