Seed data from Github package - Laravel












0















I have the following package of github loaded and installed exactly as described in the instructions:
https://github.com/igaster/laravel_cities



It all funtions everything how it should work.
The problem is that not all cities are transferred from the .txt file to the database, but only the cities with a certain size.
This is the seed file:



 class seedGeoFile extends Command
{
protected $signature = 'geo:seed {country?} {--append}';
protected $description = 'Load + Parse + Save to DB a geodata file.';
private $pdo;
private $driver;
public function __construct() {
parent::__construct();

$connection = config('database.default');
$this->driver = strtolower(config("database.connections.{$connection}.driver"));

$this->pdo = DB::connection()->getPdo(PDO::FETCH_ASSOC);
if (!Schema::hasTable('geo'))
return;
$this->geoItems = new geoCollection();
}
public function sql($sql){
$result = $this->pdo->query($sql);
if($result === false)
throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);

return $result->fetch();
}
public function buildDbTree($item, $count = 1, $depth = 0){
$item->left=$count++;
$item->depth=$depth;
foreach ($item->getChildren() as $child) {
$count = $this->buildDbTree($child, $count, $depth+1);
}
$item->right=$count++;
return $count;
}

public function printTree($item){
$levelStr= str_repeat('--', $item->depth);
$this->info(sprintf("%s %s [%d,%d]", $levelStr, $item->getName(),$item->left,$item->right));
foreach ($item->getChildren() as $child)
$this->printTree($child);
}
public function handle() {
$start = microtime(true);
$fileName = $this->argument('country') ? strtoupper($this->argument('country')) : 'allCountries';
$fileName = storage_path("geo/{$fileName}.txt");
$append = $this->option('append');
// Read Raw file
$this->info("Reading File '$fileName'");
$filesize = filesize($fileName);
$handle = fopen($fileName, 'r');
$count = 0;
$progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
while (($line = fgets($handle)) !== false) {
// ignore empty lines and comments
if ( ! $line or $line === '' or strpos($line, '#') === 0) continue;
// Convert TAB sepereted line to array
$line = explode("t", $line);
// Check for errors
if(count($line)!== 19) dd($line[0],$line[2]);
switch ($line[7]) {
case 'PCLI': // Country
case 'PPLC': // Capital
case 'ADM1':
case 'ADM2':
case 'ADM3':
$this->geoItems->add(new geoItem($line, $this->geoItems));
$count++;
break;
}
$progress = ftell($handle)/$filesize*100;
$progressBar->setProgress($progress);
}
$progressBar->finish();
$this->info(" Finished Reading File. $count items loaded</info>");
// Read hierarchy
$fileName = storage_path('geo/hierarchy.txt');
$this->info("Opening File '$fileName'</info>");
$handle = fopen($fileName, 'r');
$filesize = filesize($fileName);
$count = 0;
$progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
while (($line = fgetcsv($handle, 0, "t")) !== false) {
$parent = $item=$this->geoItems->findGeoId($line[0]);
$child = $item=$this->geoItems->findGeoId($line[1]);
if( $parent !== null && $child !== null){
$parent->addChild($line[1]);
$child->setParent($line[0]);
$count++;
}
$progress = ftell($handle)/$filesize*100;
$progressBar->setProgress($progress);
}
$this->info(" Hierarcy building completed. $count items loaded</info>");
// Build Tree
$count = 0; $countOrphan = 0;
$sql = 'SELECT MAX("right") as maxRight FROM geo';
$result = $this->sql($sql);
$maxBoundary = isset($result['maxRight']) ? $result['maxRight']+1 : 0;
foreach ($this->geoItems->items as $item) {
if($item->parentId === null){

if($item->data[7] !== 'PCLI'){
// $this->info("- Skiping Orphan {$item->data[2]} #{$item->data[0]}");
$countOrphan++;
continue;
}
$count++;
$this->info("+ Building Tree for Country: {$item->data[2]} #{$item->data[0]}");
$maxBoundary=$this->buildDbTree($item,$maxBoundary,0);
// $this->printTree($item,$output);
}
}
$this->info("Finished: {$count} Countries imported. $countOrphan orphan items skiped</info>");
// Empty Table
if (!$append){
$this->info("Truncating 'geo' table...");
DB::table('geo')->truncate();
}
// Store Tree in DB
$this->info("Writing in Database</info>");

if ($this->driver == 'mysql') {
$stmt = $this->pdo->prepare("INSERT INTO geo (`id`, `parent_id`, `left`, `right`, `depth`, `name`, `alternames`, `country`, `level`, `population`, `lat`, `long`) VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
} else {
$stmt = $this->pdo->prepare("INSERT INTO geo ("id", "parent_id", "left", "right", "depth", "name", "alternames", "country", "level", "population", "lat", "long") VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
}
$count = 0;
$totalCount = count($this->geoItems->items);
$progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
foreach ($this->geoItems->items as $item) {
if ( $stmt->execute([
':id' => $item->getId(),
':parent_id' => $item->parentId,
':left' => $item->left,
':right' => $item->right,
':depth' => $item->depth,
':name' => substr($item->data[2],0,40),
':alternames' => $item->data[3],
':country' => $item->data[8],
':level' => $item->data[7],
':population' => $item->data[14],
':lat' => $item->data[4],
':long' => $item->data[5]
]) === false){
throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);
}
$progress = $count++/$totalCount*100;
$progressBar->setProgress($progress);
}
$progressBar->finish();
$this->info(" Done</info>");
$time_elapsed_secs = microtime(true) - $start;
$this->info("Timing: $time_elapsed_secs sec</info>");
}
}


Can someone help me how I can save all cities from the .txt file to the database?
Or can someone recognize where in the code the certain cities are selected?










share|improve this question



























    0















    I have the following package of github loaded and installed exactly as described in the instructions:
    https://github.com/igaster/laravel_cities



    It all funtions everything how it should work.
    The problem is that not all cities are transferred from the .txt file to the database, but only the cities with a certain size.
    This is the seed file:



     class seedGeoFile extends Command
    {
    protected $signature = 'geo:seed {country?} {--append}';
    protected $description = 'Load + Parse + Save to DB a geodata file.';
    private $pdo;
    private $driver;
    public function __construct() {
    parent::__construct();

    $connection = config('database.default');
    $this->driver = strtolower(config("database.connections.{$connection}.driver"));

    $this->pdo = DB::connection()->getPdo(PDO::FETCH_ASSOC);
    if (!Schema::hasTable('geo'))
    return;
    $this->geoItems = new geoCollection();
    }
    public function sql($sql){
    $result = $this->pdo->query($sql);
    if($result === false)
    throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);

    return $result->fetch();
    }
    public function buildDbTree($item, $count = 1, $depth = 0){
    $item->left=$count++;
    $item->depth=$depth;
    foreach ($item->getChildren() as $child) {
    $count = $this->buildDbTree($child, $count, $depth+1);
    }
    $item->right=$count++;
    return $count;
    }

    public function printTree($item){
    $levelStr= str_repeat('--', $item->depth);
    $this->info(sprintf("%s %s [%d,%d]", $levelStr, $item->getName(),$item->left,$item->right));
    foreach ($item->getChildren() as $child)
    $this->printTree($child);
    }
    public function handle() {
    $start = microtime(true);
    $fileName = $this->argument('country') ? strtoupper($this->argument('country')) : 'allCountries';
    $fileName = storage_path("geo/{$fileName}.txt");
    $append = $this->option('append');
    // Read Raw file
    $this->info("Reading File '$fileName'");
    $filesize = filesize($fileName);
    $handle = fopen($fileName, 'r');
    $count = 0;
    $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
    while (($line = fgets($handle)) !== false) {
    // ignore empty lines and comments
    if ( ! $line or $line === '' or strpos($line, '#') === 0) continue;
    // Convert TAB sepereted line to array
    $line = explode("t", $line);
    // Check for errors
    if(count($line)!== 19) dd($line[0],$line[2]);
    switch ($line[7]) {
    case 'PCLI': // Country
    case 'PPLC': // Capital
    case 'ADM1':
    case 'ADM2':
    case 'ADM3':
    $this->geoItems->add(new geoItem($line, $this->geoItems));
    $count++;
    break;
    }
    $progress = ftell($handle)/$filesize*100;
    $progressBar->setProgress($progress);
    }
    $progressBar->finish();
    $this->info(" Finished Reading File. $count items loaded</info>");
    // Read hierarchy
    $fileName = storage_path('geo/hierarchy.txt');
    $this->info("Opening File '$fileName'</info>");
    $handle = fopen($fileName, 'r');
    $filesize = filesize($fileName);
    $count = 0;
    $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
    while (($line = fgetcsv($handle, 0, "t")) !== false) {
    $parent = $item=$this->geoItems->findGeoId($line[0]);
    $child = $item=$this->geoItems->findGeoId($line[1]);
    if( $parent !== null && $child !== null){
    $parent->addChild($line[1]);
    $child->setParent($line[0]);
    $count++;
    }
    $progress = ftell($handle)/$filesize*100;
    $progressBar->setProgress($progress);
    }
    $this->info(" Hierarcy building completed. $count items loaded</info>");
    // Build Tree
    $count = 0; $countOrphan = 0;
    $sql = 'SELECT MAX("right") as maxRight FROM geo';
    $result = $this->sql($sql);
    $maxBoundary = isset($result['maxRight']) ? $result['maxRight']+1 : 0;
    foreach ($this->geoItems->items as $item) {
    if($item->parentId === null){

    if($item->data[7] !== 'PCLI'){
    // $this->info("- Skiping Orphan {$item->data[2]} #{$item->data[0]}");
    $countOrphan++;
    continue;
    }
    $count++;
    $this->info("+ Building Tree for Country: {$item->data[2]} #{$item->data[0]}");
    $maxBoundary=$this->buildDbTree($item,$maxBoundary,0);
    // $this->printTree($item,$output);
    }
    }
    $this->info("Finished: {$count} Countries imported. $countOrphan orphan items skiped</info>");
    // Empty Table
    if (!$append){
    $this->info("Truncating 'geo' table...");
    DB::table('geo')->truncate();
    }
    // Store Tree in DB
    $this->info("Writing in Database</info>");

    if ($this->driver == 'mysql') {
    $stmt = $this->pdo->prepare("INSERT INTO geo (`id`, `parent_id`, `left`, `right`, `depth`, `name`, `alternames`, `country`, `level`, `population`, `lat`, `long`) VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
    } else {
    $stmt = $this->pdo->prepare("INSERT INTO geo ("id", "parent_id", "left", "right", "depth", "name", "alternames", "country", "level", "population", "lat", "long") VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
    }
    $count = 0;
    $totalCount = count($this->geoItems->items);
    $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
    foreach ($this->geoItems->items as $item) {
    if ( $stmt->execute([
    ':id' => $item->getId(),
    ':parent_id' => $item->parentId,
    ':left' => $item->left,
    ':right' => $item->right,
    ':depth' => $item->depth,
    ':name' => substr($item->data[2],0,40),
    ':alternames' => $item->data[3],
    ':country' => $item->data[8],
    ':level' => $item->data[7],
    ':population' => $item->data[14],
    ':lat' => $item->data[4],
    ':long' => $item->data[5]
    ]) === false){
    throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);
    }
    $progress = $count++/$totalCount*100;
    $progressBar->setProgress($progress);
    }
    $progressBar->finish();
    $this->info(" Done</info>");
    $time_elapsed_secs = microtime(true) - $start;
    $this->info("Timing: $time_elapsed_secs sec</info>");
    }
    }


    Can someone help me how I can save all cities from the .txt file to the database?
    Or can someone recognize where in the code the certain cities are selected?










    share|improve this question

























      0












      0








      0








      I have the following package of github loaded and installed exactly as described in the instructions:
      https://github.com/igaster/laravel_cities



      It all funtions everything how it should work.
      The problem is that not all cities are transferred from the .txt file to the database, but only the cities with a certain size.
      This is the seed file:



       class seedGeoFile extends Command
      {
      protected $signature = 'geo:seed {country?} {--append}';
      protected $description = 'Load + Parse + Save to DB a geodata file.';
      private $pdo;
      private $driver;
      public function __construct() {
      parent::__construct();

      $connection = config('database.default');
      $this->driver = strtolower(config("database.connections.{$connection}.driver"));

      $this->pdo = DB::connection()->getPdo(PDO::FETCH_ASSOC);
      if (!Schema::hasTable('geo'))
      return;
      $this->geoItems = new geoCollection();
      }
      public function sql($sql){
      $result = $this->pdo->query($sql);
      if($result === false)
      throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);

      return $result->fetch();
      }
      public function buildDbTree($item, $count = 1, $depth = 0){
      $item->left=$count++;
      $item->depth=$depth;
      foreach ($item->getChildren() as $child) {
      $count = $this->buildDbTree($child, $count, $depth+1);
      }
      $item->right=$count++;
      return $count;
      }

      public function printTree($item){
      $levelStr= str_repeat('--', $item->depth);
      $this->info(sprintf("%s %s [%d,%d]", $levelStr, $item->getName(),$item->left,$item->right));
      foreach ($item->getChildren() as $child)
      $this->printTree($child);
      }
      public function handle() {
      $start = microtime(true);
      $fileName = $this->argument('country') ? strtoupper($this->argument('country')) : 'allCountries';
      $fileName = storage_path("geo/{$fileName}.txt");
      $append = $this->option('append');
      // Read Raw file
      $this->info("Reading File '$fileName'");
      $filesize = filesize($fileName);
      $handle = fopen($fileName, 'r');
      $count = 0;
      $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
      while (($line = fgets($handle)) !== false) {
      // ignore empty lines and comments
      if ( ! $line or $line === '' or strpos($line, '#') === 0) continue;
      // Convert TAB sepereted line to array
      $line = explode("t", $line);
      // Check for errors
      if(count($line)!== 19) dd($line[0],$line[2]);
      switch ($line[7]) {
      case 'PCLI': // Country
      case 'PPLC': // Capital
      case 'ADM1':
      case 'ADM2':
      case 'ADM3':
      $this->geoItems->add(new geoItem($line, $this->geoItems));
      $count++;
      break;
      }
      $progress = ftell($handle)/$filesize*100;
      $progressBar->setProgress($progress);
      }
      $progressBar->finish();
      $this->info(" Finished Reading File. $count items loaded</info>");
      // Read hierarchy
      $fileName = storage_path('geo/hierarchy.txt');
      $this->info("Opening File '$fileName'</info>");
      $handle = fopen($fileName, 'r');
      $filesize = filesize($fileName);
      $count = 0;
      $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
      while (($line = fgetcsv($handle, 0, "t")) !== false) {
      $parent = $item=$this->geoItems->findGeoId($line[0]);
      $child = $item=$this->geoItems->findGeoId($line[1]);
      if( $parent !== null && $child !== null){
      $parent->addChild($line[1]);
      $child->setParent($line[0]);
      $count++;
      }
      $progress = ftell($handle)/$filesize*100;
      $progressBar->setProgress($progress);
      }
      $this->info(" Hierarcy building completed. $count items loaded</info>");
      // Build Tree
      $count = 0; $countOrphan = 0;
      $sql = 'SELECT MAX("right") as maxRight FROM geo';
      $result = $this->sql($sql);
      $maxBoundary = isset($result['maxRight']) ? $result['maxRight']+1 : 0;
      foreach ($this->geoItems->items as $item) {
      if($item->parentId === null){

      if($item->data[7] !== 'PCLI'){
      // $this->info("- Skiping Orphan {$item->data[2]} #{$item->data[0]}");
      $countOrphan++;
      continue;
      }
      $count++;
      $this->info("+ Building Tree for Country: {$item->data[2]} #{$item->data[0]}");
      $maxBoundary=$this->buildDbTree($item,$maxBoundary,0);
      // $this->printTree($item,$output);
      }
      }
      $this->info("Finished: {$count} Countries imported. $countOrphan orphan items skiped</info>");
      // Empty Table
      if (!$append){
      $this->info("Truncating 'geo' table...");
      DB::table('geo')->truncate();
      }
      // Store Tree in DB
      $this->info("Writing in Database</info>");

      if ($this->driver == 'mysql') {
      $stmt = $this->pdo->prepare("INSERT INTO geo (`id`, `parent_id`, `left`, `right`, `depth`, `name`, `alternames`, `country`, `level`, `population`, `lat`, `long`) VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
      } else {
      $stmt = $this->pdo->prepare("INSERT INTO geo ("id", "parent_id", "left", "right", "depth", "name", "alternames", "country", "level", "population", "lat", "long") VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
      }
      $count = 0;
      $totalCount = count($this->geoItems->items);
      $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
      foreach ($this->geoItems->items as $item) {
      if ( $stmt->execute([
      ':id' => $item->getId(),
      ':parent_id' => $item->parentId,
      ':left' => $item->left,
      ':right' => $item->right,
      ':depth' => $item->depth,
      ':name' => substr($item->data[2],0,40),
      ':alternames' => $item->data[3],
      ':country' => $item->data[8],
      ':level' => $item->data[7],
      ':population' => $item->data[14],
      ':lat' => $item->data[4],
      ':long' => $item->data[5]
      ]) === false){
      throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);
      }
      $progress = $count++/$totalCount*100;
      $progressBar->setProgress($progress);
      }
      $progressBar->finish();
      $this->info(" Done</info>");
      $time_elapsed_secs = microtime(true) - $start;
      $this->info("Timing: $time_elapsed_secs sec</info>");
      }
      }


      Can someone help me how I can save all cities from the .txt file to the database?
      Or can someone recognize where in the code the certain cities are selected?










      share|improve this question














      I have the following package of github loaded and installed exactly as described in the instructions:
      https://github.com/igaster/laravel_cities



      It all funtions everything how it should work.
      The problem is that not all cities are transferred from the .txt file to the database, but only the cities with a certain size.
      This is the seed file:



       class seedGeoFile extends Command
      {
      protected $signature = 'geo:seed {country?} {--append}';
      protected $description = 'Load + Parse + Save to DB a geodata file.';
      private $pdo;
      private $driver;
      public function __construct() {
      parent::__construct();

      $connection = config('database.default');
      $this->driver = strtolower(config("database.connections.{$connection}.driver"));

      $this->pdo = DB::connection()->getPdo(PDO::FETCH_ASSOC);
      if (!Schema::hasTable('geo'))
      return;
      $this->geoItems = new geoCollection();
      }
      public function sql($sql){
      $result = $this->pdo->query($sql);
      if($result === false)
      throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);

      return $result->fetch();
      }
      public function buildDbTree($item, $count = 1, $depth = 0){
      $item->left=$count++;
      $item->depth=$depth;
      foreach ($item->getChildren() as $child) {
      $count = $this->buildDbTree($child, $count, $depth+1);
      }
      $item->right=$count++;
      return $count;
      }

      public function printTree($item){
      $levelStr= str_repeat('--', $item->depth);
      $this->info(sprintf("%s %s [%d,%d]", $levelStr, $item->getName(),$item->left,$item->right));
      foreach ($item->getChildren() as $child)
      $this->printTree($child);
      }
      public function handle() {
      $start = microtime(true);
      $fileName = $this->argument('country') ? strtoupper($this->argument('country')) : 'allCountries';
      $fileName = storage_path("geo/{$fileName}.txt");
      $append = $this->option('append');
      // Read Raw file
      $this->info("Reading File '$fileName'");
      $filesize = filesize($fileName);
      $handle = fopen($fileName, 'r');
      $count = 0;
      $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
      while (($line = fgets($handle)) !== false) {
      // ignore empty lines and comments
      if ( ! $line or $line === '' or strpos($line, '#') === 0) continue;
      // Convert TAB sepereted line to array
      $line = explode("t", $line);
      // Check for errors
      if(count($line)!== 19) dd($line[0],$line[2]);
      switch ($line[7]) {
      case 'PCLI': // Country
      case 'PPLC': // Capital
      case 'ADM1':
      case 'ADM2':
      case 'ADM3':
      $this->geoItems->add(new geoItem($line, $this->geoItems));
      $count++;
      break;
      }
      $progress = ftell($handle)/$filesize*100;
      $progressBar->setProgress($progress);
      }
      $progressBar->finish();
      $this->info(" Finished Reading File. $count items loaded</info>");
      // Read hierarchy
      $fileName = storage_path('geo/hierarchy.txt');
      $this->info("Opening File '$fileName'</info>");
      $handle = fopen($fileName, 'r');
      $filesize = filesize($fileName);
      $count = 0;
      $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
      while (($line = fgetcsv($handle, 0, "t")) !== false) {
      $parent = $item=$this->geoItems->findGeoId($line[0]);
      $child = $item=$this->geoItems->findGeoId($line[1]);
      if( $parent !== null && $child !== null){
      $parent->addChild($line[1]);
      $child->setParent($line[0]);
      $count++;
      }
      $progress = ftell($handle)/$filesize*100;
      $progressBar->setProgress($progress);
      }
      $this->info(" Hierarcy building completed. $count items loaded</info>");
      // Build Tree
      $count = 0; $countOrphan = 0;
      $sql = 'SELECT MAX("right") as maxRight FROM geo';
      $result = $this->sql($sql);
      $maxBoundary = isset($result['maxRight']) ? $result['maxRight']+1 : 0;
      foreach ($this->geoItems->items as $item) {
      if($item->parentId === null){

      if($item->data[7] !== 'PCLI'){
      // $this->info("- Skiping Orphan {$item->data[2]} #{$item->data[0]}");
      $countOrphan++;
      continue;
      }
      $count++;
      $this->info("+ Building Tree for Country: {$item->data[2]} #{$item->data[0]}");
      $maxBoundary=$this->buildDbTree($item,$maxBoundary,0);
      // $this->printTree($item,$output);
      }
      }
      $this->info("Finished: {$count} Countries imported. $countOrphan orphan items skiped</info>");
      // Empty Table
      if (!$append){
      $this->info("Truncating 'geo' table...");
      DB::table('geo')->truncate();
      }
      // Store Tree in DB
      $this->info("Writing in Database</info>");

      if ($this->driver == 'mysql') {
      $stmt = $this->pdo->prepare("INSERT INTO geo (`id`, `parent_id`, `left`, `right`, `depth`, `name`, `alternames`, `country`, `level`, `population`, `lat`, `long`) VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
      } else {
      $stmt = $this->pdo->prepare("INSERT INTO geo ("id", "parent_id", "left", "right", "depth", "name", "alternames", "country", "level", "population", "lat", "long") VALUES (:id, :parent_id, :left, :right, :depth, :name, :alternames, :country, :level, :population, :lat, :long)");
      }
      $count = 0;
      $totalCount = count($this->geoItems->items);
      $progressBar = new SymfonyComponentConsoleHelperProgressBar($this->output, 100);
      foreach ($this->geoItems->items as $item) {
      if ( $stmt->execute([
      ':id' => $item->getId(),
      ':parent_id' => $item->parentId,
      ':left' => $item->left,
      ':right' => $item->right,
      ':depth' => $item->depth,
      ':name' => substr($item->data[2],0,40),
      ':alternames' => $item->data[3],
      ':country' => $item->data[8],
      ':level' => $item->data[7],
      ':population' => $item->data[14],
      ':lat' => $item->data[4],
      ':long' => $item->data[5]
      ]) === false){
      throw new Exception("Error in SQL : '$sql'n".PDO::errorInfo(), 1);
      }
      $progress = $count++/$totalCount*100;
      $progressBar->setProgress($progress);
      }
      $progressBar->finish();
      $this->info(" Done</info>");
      $time_elapsed_secs = microtime(true) - $start;
      $this->info("Timing: $time_elapsed_secs sec</info>");
      }
      }


      Can someone help me how I can save all cities from the .txt file to the database?
      Or can someone recognize where in the code the certain cities are selected?







      laravel github seed






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 12:06









      slicknessslickness

      1189




      1189
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006065%2fseed-data-from-github-package-laravel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006065%2fseed-data-from-github-package-laravel%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          Npm cannot find a required file even through it is in the searched directory