public function syncDatabase()
  {
    $tmpname = '/tmp/odango.php.cache';

    if (!file_exists($tmpname)) {
      $curl = new Curl();
      $curl->setOpt(CURLOPT_ENCODING, "gzip");
      $curl->download($this->titleDumpUrl, $tmpname);
      $curl->close();
    }

    $this->db->exec('START TRANSACTION');
    $this->db->exec('DELETE FROM ' . $this->table);

    $xml = simplexml_load_file($tmpname);
    foreach ($xml as $child) {
      $aid = (int)$child['aid'];
      $added = [];
      foreach($child->title as $title) {
        $type = (string)$title['type'];
        $lang = (string)$title->attributes('xml', true)['lang'];

        if ($lang == 'x-jat' || $lang == 'en') {

          if (!in_array((string)$title, $added)) {
            $added[] = (string)$title;

            $this->model->insert([
              'aniDbId'   => $aid,
              'title'     => (string)$title,
              'isDefault' => $type == 'main' ? 1 :0
            ]);
          } else if ( $type == 'main' ) {
            $this->model->update(['isDefault' => 1], 'AniDbId = '.$aid.' AND title = '.$this->db->quote((string)$title));
          }
        }
      }
    }

    $this->db->exec('COMMIT');
  }