Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit bfc3d2e

Browse files
authored
Update IpGeoBase.php
1 parent ae810f7 commit bfc3d2e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/IpGeoBase.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ public function setUploadDir(string $path) : IpGeoBase {
2929
$this->uploadDir = $path;
3030
return $this;
3131
}
32-
32+
/**
33+
* IpGeoBase constructor.
34+
* @param PDO|string $pdo Instance PDO object or dsn string
35+
* @param null $user
36+
* @param null $password
37+
*/
3338
public function __construct($pdo, $user = null, $password = null){
3439
if(!$pdo instanceof PDO){
3540
$pdo = new PDO($pdo, $user, $password);
@@ -127,7 +132,7 @@ public function update(){
127132
foreach($file as $row){
128133
$row = iconv('windows-1251', 'utf-8', $row);
129134
$row = trim(str_replace(' ', '&', $row));
130-
if($sth === null){
135+
if(!isset($sth)){
131136
$sth = $this->pdo->prepare("INSERT INTO geobase_cities (city_id, city, region, district, latitude, longitude) VALUES (:id, :city, :reg, :dist, :lat, :lon)");
132137
}
133138
$ex = explode('&', $row);
@@ -152,7 +157,7 @@ public function update(){
152157
foreach($file as $row){
153158
$row = iconv('windows-1251', 'utf-8', $row);
154159
$row = trim(str_replace([' ', ' - '],' ', $row));
155-
if($sth === null){
160+
if(!isset($sth)){
156161
$sth = $this->pdo->prepare("INSERT INTO geobase (long_ip1, long_ip2, ip1, ip2, country, city_id) VALUES (:lon1, :lon2, :ip1, :ip2, :country, :city_id )");
157162
}
158163
$ex = explode(' ', $row);

0 commit comments

Comments
 (0)