Exemple #1
0
include_once "Source/Models/Logger.php";
include_once "Source/Database/Database.php";
include_once "Source/Factories/DatabaseFactory.php";
$csvParser = new CSVParser();
$logger = new Logger();
$fileUri = "db.csv";
$loggerUri = "Log/Log";
// functie maken die fout in bestand set write2errorfile(dataArray)
// controler vast tel nummer toevoegen
$csvParser->setFileUri($fileUri);
// Kijkt dat file bestaat
if ($csvParser->checkIfFileExist()) {
    // Lees regel CSV bestand
    $row = 0;
    $dataArray = [];
    if ($csvParser->setHandle($csvParser->openFile("r")) !== FALSE) {
        // Controleert of data is gevonden
        while (($data = $csvParser->lineCSV($csvParser->getHandle())) !== FALSE) {
            if ($row == 0) {
                $row++;
                continue;
            }
            $num = count($data);
            // Zet regel op het scherm
            echo "<p> {$num} velden in lijn {$row}: <br /></p>\n";
            $database = DatabaseFactory::getDatabase();
            $user = new UserController(new DbUser($database));
            $user->setFirstName($data[DATA_POS_FN]);
            $user->setLastName($data[DATA_POS_LN]);
            $user->setMobile($data[DATA_POS_MOB]);
            $user->setTelephone($data[DATA_POS_TEL]);