ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilArrayTableDataParser Class Reference
+ Collaboration diagram for ilArrayTableDataParser:

Public Member Functions

 __construct ($data_dir)
 
 startParsing ()
 

Protected Attributes

 $dir = null
 
 $value = ''
 

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 8 of file class.ilArrayTableDataParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilArrayTableDataParser::__construct (   $data_dir)

Definition at line 14 of file class.ilArrayTableDataParser.php.

15 {
16 $this->dir = $data_dir;
17 }

Member Function Documentation

◆ startParsing()

ilArrayTableDataParser::startParsing ( )

Definition at line 19 of file class.ilArrayTableDataParser.php.

20 {
21 global $DIC;
22 $ilDB = $DIC->database();
23 $ilLogger = $DIC->logger()->root();
24
25 if (!$dp = opendir($this->dir)) {
26 $ilLogger->error(__METHOD__ . ': Cannot open data directory: ' . $this->dir);
27 return false;
28 }
29
30 $ilLogger->log(__METHOD__ . ': Reading table data from: ' . $this->dir);
31 while (false !== ($file = readdir($dp))) {
32 $ilLogger->log(__METHOD__ . ': Handling file: ' . $file);
33 if (substr($file, -5) != '.data') {
34 $ilLogger->log(__METHOD__ . ': Ignoring file: ' . $file);
35 continue;
36 }
37
38 $content = file_get_contents($this->dir . DIRECTORY_SEPARATOR . $file);
39
40 $ilLogger->log(__METHOD__ . ': Reading inserts of ' . $this->dir . '/' . $file);
41 $content = unserialize($content);
42
43 if (!is_array($content)) {
44 $ilLogger->log(__METHOD__ . ': No entries found in ' . $this->dir . '/' . $file);
45 continue;
46 }
47
48 foreach ($content as $table => $rows) {
49 foreach ($rows as $row) {
50 $ilDB->insert($table, $row);
51 }
52 }
53 if (function_exists('memory_get_usage')) {
54 $ilLogger->log(__METHOD__ . ': Memory usage ' . memory_get_usage(true));
55 }
56 }
57 fclose($dp);
58 }
global $ilDB
$DIC
Definition: xapitoken.php:46
$rows
Definition: xhr_table.php:10

References $DIC, $ilDB, and $rows.

Field Documentation

◆ $dir

ilArrayTableDataParser::$dir = null
protected

Definition at line 10 of file class.ilArrayTableDataParser.php.

◆ $value

ilArrayTableDataParser::$value = ''
protected

Definition at line 12 of file class.ilArrayTableDataParser.php.


The documentation for this class was generated from the following file: