/** * Insert one row to DB * * @param string $row * * @return bool * * @author Kondratenko Alexander (Xander) */ public static function add($row) { $row = array_values(explode(self::value_delimeter, $row)); if (empty($row[0])) { return FALSE; } $data = array('transaction_id' => trim($row[0]), 'tdate' => trim($row[1]), 'tvalue' => trim($row[2])); if (self::validate($data) === TRUE) { FileLogs::insert($data); return TRUE; } return FALSE; }
public function start() { echo "Reading & Inserting <br/>"; $file = \File::get(public_path($this->file)); $i = 0; foreach (explode($this->end_of_line, $file) as $row) { if (FileLogs::add($row)) { $i++; } } if ($i > 0) { echo "Success insert: {$i} rows<br/>"; } else { echo "No rows was inserted<br/>"; } // remove File if (\File::delete(public_path($this->file))) { echo "File has been deleted!<br/>"; } return; }