File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -192,22 +192,21 @@ public static function loadFromFile(Connection $connection, $file): int
192192 $ delimiter = '; ' ;
193193 $ sql = '' ;
194194 $ pdo = $ connection ->getPdo (); // native query without logging
195- while (!feof ($ handle )) {
196- $ s = rtrim ((string ) fgets ($ handle ));
195+ while (($ s = fgets ($ handle )) !== FALSE ) {
197196 if (!strncasecmp ($ s , 'DELIMITER ' , 10 )) {
198- $ delimiter = substr ($ s , 10 );
197+ $ delimiter = trim ( substr ($ s , 10 ) );
199198
200- } elseif (substr ($ s , -strlen ($ delimiter )) === $ delimiter ) {
201- $ sql .= substr ($ s , 0 , -strlen ($ delimiter ));
199+ } elseif (substr ($ ts = rtrim ( $ s ) , -strlen ($ delimiter )) === $ delimiter ) {
200+ $ sql .= substr ($ ts , 0 , -strlen ($ delimiter ));
202201 $ pdo ->exec ($ sql );
203202 $ sql = '' ;
204203 $ count ++;
205204
206205 } else {
207- $ sql .= $ s . "\n" ;
206+ $ sql .= $ s ;
208207 }
209208 }
210- if (trim ($ sql ) !== '' ) {
209+ if (rtrim ($ sql ) !== '' ) {
211210 $ pdo ->exec ($ sql );
212211 $ count ++;
213212 }
You can’t perform that action at this time.
0 commit comments