diff options
author | Kandrashin Denis <mail@lintest.ru> | 2010-10-26 16:12:35 +0400 |
---|---|---|
committer | Kandrashin Denis <mail@lintest.ru> | 2010-10-26 16:12:35 +0400 |
commit | 611baa926ec05c16b9d909138fc6092929d223ae (patch) | |
tree | 27cf147a2e43745d0d54bd2e2904d5bca061bbf6 /scripts | |
parent | 3522000b418725287c501581a0ff31c931609d2b (diff) |
modify Flibusta convert script
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Common/database.php | 69 | ||||
-rw-r--r-- | scripts/Common/datafile.php | 102 | ||||
-rw-r--r-- | scripts/Common/genres.php | 142 | ||||
-rw-r--r-- | scripts/Common/strutils.php | 59 | ||||
-rw-r--r-- | scripts/Flibusta/conv_book.php | 199 |
5 files changed, 403 insertions, 168 deletions
diff --git a/scripts/Common/database.php b/scripts/Common/database.php new file mode 100644 index 00000000..a361aac6 --- /dev/null +++ b/scripts/Common/database.php @@ -0,0 +1,69 @@ +<?php + +function CreateTables($sqlite_db) +{ + $sqlite_db->query("begin transaction"); + + $sqlite_db->query(" + CREATE TABLE a( + Aid integer primary key, + First text, + Middle text, + Last text, + Full varchar(255), + Find varchar(255), + Letter char(1), + Numb integer, + Dscr text); + "); + + $sqlite_db->query(" + CREATE TABLE b( + Bid integer primary key, + Zid integer, + Aid integer, + Title varchar(255) not null, + File text, + Path text, + Size integer, + Type text, + Md5s text, + Genr text, + Lang text, + Date integer, + Year integer, + Dscr text); + "); + + $sqlite_db->query(" + CREATE TABLE s( + Sid integer primary key, + Seqn text, + Numb integer); + "); + + $sqlite_db->query(" + CREATE TABLE ba( + Bid integer not null, + Aid integer); + "); + + $sqlite_db->query(" + CREATE TABLE bg( + Bid integer not null, + Gid text); + "); + + $sqlite_db->query(" + CREATE TABLE bs( + Bid integer not null, + Sid integer, + Num integer); + "); + + $sqlite_db->query("CREATE TABLE params(id integer primary key, value text)"); + + $sqlite_db->query("commit"); +} + +?> diff --git a/scripts/Common/datafile.php b/scripts/Common/datafile.php new file mode 100644 index 00000000..04ebe568 --- /dev/null +++ b/scripts/Common/datafile.php @@ -0,0 +1,102 @@ +<?php + +function create_tables($sqlite_db) +{ + $sqlite_db->query("begin transaction;"); + + $sqlite_db->query("DROP TABLE IF EXISTS authors"); + $sqlite_db->query(" + CREATE TABLE authors( + id integer primary key, + letter char(1), + search_name varchar(255), + full_name varchar(255), + first_name varchar(128), + middle_name varchar(128), + last_name varchar(128), + number integer, + newid integer, + description text); + "); + + $sqlite_db->query("DROP TABLE IF EXISTS books"); + $sqlite_db->query(" + CREATE TABLE books( + id integer not null, + id_author integer, + title varchar(255) not null, + annotation text, + genres text, + id_sequence integer, + deleted boolean, + id_archive integer, + file_name text, + file_size integer, + file_type varchar(20), + md5sum char(32), + created integer, + lang char(2), + year integer, + description text); + "); + + $sqlite_db->query("DROP TABLE IF EXISTS sequences"); + $sqlite_db->query("CREATE TABLE sequences(id integer primary key, number integer, value varchar(255) not null)"); + + $sqlite_db->query("DROP TABLE IF EXISTS bookseq"); + $sqlite_db->query("CREATE TABLE bookseq(id_book integer, id_seq integer, number integer, level integer, id_author integer)"); + + $sqlite_db->query("DROP TABLE IF EXISTS genres"); + $sqlite_db->query("CREATE TABLE genres(id_book integer, id_genre CHAR(2))"); + + $sqlite_db->query("DROP TABLE IF EXISTS params"); + $sqlite_db->query("CREATE TABLE params(id integer primary key, value integer, text text)"); + + $sqlite_db->query("commit;"); +} + +function create_indexes($sqlite_db) +{ + $sqlite_db->query("begin transaction;"); + + $sqlite_db->query(" + CREATE TABLE archives( + id integer primary key, + file_name varchar(255), + file_path varchar(255), + file_size integer, + file_count integer, + min_id_book integer, + max_id_book integer, + file_type varchar(20), + description text); + "); + + $sqlite_db->query("CREATE INDEX author_letter ON authors(letter);"); + $sqlite_db->query("CREATE INDEX author_name ON authors(search_name);"); + + $sqlite_db->query("CREATE INDEX book_id ON books(id);"); + $sqlite_db->query("CREATE INDEX book_author ON books(id_author);"); + $sqlite_db->query("CREATE INDEX book_archive ON books(id_archive);"); + $sqlite_db->query("CREATE INDEX book_md5sum ON books(md5sum);"); + $sqlite_db->query("CREATE INDEX book_created ON books(created);"); + + $sqlite_db->query("CREATE INDEX book_file ON archives(file_name);"); + + $sqlite_db->query("CREATE INDEX sequences_name ON sequences(value);"); + + $sqlite_db->query("CREATE INDEX bookseq_book ON bookseq(id_book);"); + $sqlite_db->query("CREATE INDEX bookseq_author ON bookseq(id_author);"); + + $sqlite_db->query("CREATE INDEX aliases_author ON aliases(id_author);"); + $sqlite_db->query("CREATE INDEX aliases_alias ON aliases(id_alias);"); + + $sqlite_db->query("CREATE INDEX genres_book ON genres(id_book);"); + $sqlite_db->query("CREATE INDEX genres_genre ON genres(id_genre);"); + + $sqlite_db->query("commit;"); + + $sqlite_db->query("vacuum;"); +} + +?> diff --git a/scripts/Common/genres.php b/scripts/Common/genres.php new file mode 100644 index 00000000..efa24cb1 --- /dev/null +++ b/scripts/Common/genres.php @@ -0,0 +1,142 @@ +<?php + +function GenreCode($s) +{ + global $genreArray; + if(!isset($genreArray)){ + $genreArray = array( + "sf_history" => "11", + "sf_action" => "12", + "sf_epic" => "13", + "sf_heroic" => "14", + "sf_detective" => "15", + "sf_cyberpunk" => "16", + "sf_space" => "17", + "sf_social" => "18", + "sf_horror" => "19", + "sf_humor" => "1A", + "sf_fantasy" => "1B", + "sf" => "10", + "det_classic" => "21", + "det_police" => "22", + "det_action" => "23", + "det_irony" => "24", + "det_history" => "25", + "det_espionage" => "26", + "det_crime" => "27", + "det_political" => "28", + "det_maniac" => "29", + "det_hard" => "2A", + "thriller" => "2B", + "detective" => "20", + "prose_classic" => "31", + "prose_history" => "32", + "prose_contemporary" => "33", + "prose_counter" => "34", + "prose_rus_classic" => "35", + "prose_su_classics" => "36", + "prose_military" => "37", + "prose" => "30", + "love_contemporary" => "41", + "love_history" => "42", + "love_detective" => "43", + "love_short" => "44", + "love_erotica" => "45", + "love" => "40", + "adv_western" => "51", + "adv_history" => "52", + "adv_indian" => "53", + "adv_maritime" => "54", + "adv_geo" => "55", + "adv_animal" => "56", + "adventure" => "50", + "child_tale" => "61", + "child_verse" => "62", + "child_prose" => "63", + "child_sf" => "64", + "child_det" => "65", + "child_adv" => "66", + "child_education" => "67", + "children" => "60", + "poetry" => "71", + "dramaturgy" => "72", + "antique_ant" => "81", + "antique_european" => "82", + "antique_russian" => "83", + "antique_east" => "84", + "antique_myths" => "85", + "antique" => "80", + "sci_history" => "91", + "sci_psychology" => "92", + "sci_culture" => "93", + "sci_religion" => "94", + "sci_philosophy" => "95", + "sci_politics" => "96", + "sci_business" => "97", + "sci_juris" => "98", + "sci_linguistic" => "99", + "sci_medicine" => "9A", + "sci_phys" => "9B", + "sci_math" => "9C", + "sci_chem" => "9D", + "sci_biology" => "9E", + "sci_tech" => "9F", + "science" => "90", + "comp_www" => "A1", + "comp_programming" => "A2", + "comp_hard" => "A3", + "comp_soft" => "A4", + "comp_db" => "A5", + "comp_osnet" => "A6", + "computers" => "A0", + "ref_encyc" => "B1", + "ref_dict" => "B2", + "ref_ref" => "B3", + "ref_guide" => "B4", + "reference" => "B0", + "nonf_biography" => "C1", + "nonf_publicism" => "C2", + "nonf_criticism" => "C3", + "design" => "C4", + "nonfiction" => "C5", + "religion_rel" => "D1", + "religion_esoterics" => "D2", + "religion_self" => "D3", + "religion" => "D0", + "humor_anecdote" => "E1", + "humor_prose" => "E2", + "humor_verse" => "E3", + "humor" => "E0", + "home_cooking" => "F1", + "home_pets" => "F2", + "home_crafts" => "F3", + "home_entertain" => "F4", + "home_health" => "F5", + "home_garden" => "F6", + "home_diy" => "F7", + "home_sport" => "F8", + "home_sex" => "F9", + "home" => "F0", + "geo_guides" => "FA", + "job_hunting" => "01", + "management" => "02", + "marketing" => "03", + "banking" => "04", + "stock" => "05", + "accounting" => "06", + "global_economy" => "07", + "economics" => "00", + "industries" => "08", + "org_behavior" => "09", + "personal_finance" => "0A", + "real_estate" => "0B", + "popular_business" => "0C", + "small_business" => "0D", + "paper_work" => "0E", + "economics_ref" => "0F", + ); + } + return $genreArray[$s]; +} + +?> diff --git a/scripts/Common/strutils.php b/scripts/Common/strutils.php new file mode 100644 index 00000000..e5531d6f --- /dev/null +++ b/scripts/Common/strutils.php @@ -0,0 +1,59 @@ +<?php + +function strtolowerEx($str){ + $result = $str; + global $strtolowerEx_pairs; + if(!isset($strtolowerEx_pairs)){ + $from = 'А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'; + $to = 'а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я a b c d e f g h i j k l m n o p q r s t u v w x y z'; + $from = explode(' ', trim($from)); + $to = explode(' ', trim($to)); + $cfrom = count($from); + $cto = count($to); + $count = $cfrom > $cto ? $cto : $cfrom; + for($i = 0; $i < $count; $i++){$strtolowerEx_pairs[$from[$i]] = $to[$i];} + } + $result = strtr($str, $strtolowerEx_pairs); + return $result; +} + +function utf8_strlen($s) +{ + return preg_match_all('/./u', $s, $tmp); +} + +function strtoupperEx($str){ + $result = $str; + global $strtoupperEx_pairs; + if(!isset($strtoupperEx_pairs)){ + $from = 'а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я a b c d e f g h i j k l m n o p q r s t u v w x y z Ё'; + $to = 'А Б В Г Д Е Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Е'; + $from = explode(' ', trim($from)); + $to = explode(' ', trim($to)); + $cfrom = count($from); + $cto = count($to); + $count = $cfrom > $cto ? $cto : $cfrom; + for($i = 0; $i < $count; $i++){$strtoupperEx_pairs[$from[$i]] = $to[$i];} + } + $result = strtr($str, $strtoupperEx_pairs); + return $result; +} + +function utf8_substr($s, $offset, $len = 'all') +{ + if ($offset<0) $offset = utf8_strlen($s) + $offset; + if ($len!='all') + { + if ($len<0) $len = utf8_strlen($s) - $offset + $len; + $xlen = utf8_strlen($s) - $offset; + $len = ($len>$xlen) ? $xlen : $len; + preg_match('/^.{' . $offset . '}(.{0,'.$len.'})/us', $s, $tmp); + } + else + { + preg_match('/^.{' . $offset . '}(.*)/us', $s, $tmp); + } + return (isset($tmp[1])) ? $tmp[1] : false; +} + +?> diff --git a/scripts/Flibusta/conv_book.php b/scripts/Flibusta/conv_book.php index 1fa29784..1ed81198 100644 --- a/scripts/Flibusta/conv_book.php +++ b/scripts/Flibusta/conv_book.php @@ -1,62 +1,8 @@ <?php -require_once 'genres.php'; - -function strtolowerEx($str){ - $result = $str; - global $strtolowerEx_pairs; - if(!isset($strtolowerEx_pairs)){ - $from = 'А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'; - $to = 'а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я a b c d e f g h i j k l m n o p q r s t u v w x y z'; - $from = explode(' ', trim($from)); - $to = explode(' ', trim($to)); - $cfrom = count($from); - $cto = count($to); - $count = $cfrom > $cto ? $cto : $cfrom; - for($i = 0; $i < $count; $i++){$strtolowerEx_pairs[$from[$i]] = $to[$i];} - } - $result = strtr($str, $strtolowerEx_pairs); - return $result; -} - -function utf8_strlen($s) -{ - return preg_match_all('/./u', $s, $tmp); -} - -function strtoupperEx($str){ - $result = $str; - global $strtoupperEx_pairs; - if(!isset($strtoupperEx_pairs)){ - $from = 'а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я a b c d e f g h i j k l m n o p q r s t u v w x y z Ё'; - $to = 'А Б В Г Д Е Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Е'; - $from = explode(' ', trim($from)); - $to = explode(' ', trim($to)); - $cfrom = count($from); - $cto = count($to); - $count = $cfrom > $cto ? $cto : $cfrom; - for($i = 0; $i < $count; $i++){$strtoupperEx_pairs[$from[$i]] = $to[$i];} - } - $result = strtr($str, $strtoupperEx_pairs); - return $result; -} - -function utf8_substr($s, $offset, $len = 'all') -{ - if ($offset<0) $offset = utf8_strlen($s) + $offset; - if ($len!='all') - { - if ($len<0) $len = utf8_strlen($s) - $offset + $len; - $xlen = utf8_strlen($s) - $offset; - $len = ($len>$xlen) ? $xlen : $len; - preg_match('/^.{' . $offset . '}(.{0,'.$len.'})/us', $s, $tmp); - } - else - { - preg_match('/^.{' . $offset . '}(.*)/us', $s, $tmp); - } - return (isset($tmp[1])) ? $tmp[1] : false; -} +require_once '../Common/datafile.php'; +require_once '../Common/genres.php'; +require_once '../Common/strutils.php'; function convert_authors($mysql_db, $sqlite_db, $min) { @@ -88,7 +34,7 @@ function convert_authors($mysql_db, $sqlite_db, $min) if (strpos($char_list, $letter) === false) { $letter = "#"; }; - echo $row['AvtorId']." - ".$letter." - ".$full_name." - ".$search_name."\n"; + echo "Auth: ".$row['AvtorId']." - ".$letter." - ".$full_name." - ".$search_name."\n"; $sql = "INSERT INTO authors (id, number, letter, full_name, search_name, first_name, middle_name, last_name) VALUES(?,?,?,?,?,?,?,?)"; $insert = $sqlite_db->prepare($sql); @@ -115,7 +61,7 @@ function convert_genres($mysql_db, $sqlite_db, $min) $query = $mysql_db->query($sqltext); while ($row = $query->fetch_array()) { $genre = GenreCode($row['GenreCode']); - echo $row['GenreCode']." - ".$row['BookId']." - ".$genre."\n"; + echo "Genr: ".$row['GenreCode']." - ".$row['BookId']." - ".$genre."\n"; if (!empty($genre)) { $sql = "INSERT INTO genres(id_book, id_genre) VALUES(?,?)"; $insert = $sqlite_db->prepare($sql); @@ -149,7 +95,7 @@ function convert_books($mysql_db, $sqlite_db, $min) $query = $mysql_db->query($sqltest); while ($row = $query->fetch_array()) { - echo $row['Time']." - ".$row['BookId']." - ".$row['FileType']." - ".$row['AvtorId']." - ".$row['Title']."\n"; + echo "Book: ".$row['Time']." - ".$row['BookId']." - ".$row['FileType']." - ".$row['AvtorId']." - ".$row['Title']."\n"; $genres = ""; $subsql = "SELECT GenreCode FROM libgenre LEFT JOIN libgenrelist ON libgenre.GenreId = libgenrelist.GenreId WHERE BookId=".$row['BookId']; @@ -185,13 +131,13 @@ function convert_dates($mysql_db, $sqlite_db, $min) $sqltest = " SELECT DATE_FORMAT(Time,'%y%m%d') as Time, MAX(BookId) as Max, MIN(BookId) as Min, COUNT(BookId) AS Num FROM libbook - WHERE Deleted<>1 + WHERE Deleted<>1 AND libbook.BookId>$min GROUP BY DATE_FORMAT(libbook.Time,'%y%m%d') "; $query = $mysql_db->query($sqltest); while ($row = $query->fetch_array()) { - echo $row['Time']." - ".$row['Max']." - ".$row['Min']."\n"; + echo "Date: ".$row['Time']." - ".$row['Max']." - ".$row['Min']."\n"; $sql = "INSERT INTO dates (id, lib_max, lib_min, lib_num) VALUES(?,?,?,?)"; $insert = $sqlite_db->prepare($sql); if($insert === false){ $err= $dbh->errorInfo(); die($err[2]); } @@ -220,7 +166,7 @@ function convert_seqnames($mysql_db, $sqlite_db, $min) $query = $mysql_db->query($sqltest); while ($row = $query->fetch_array()) { - echo $row['SeqId']." - ".$row['SeqName']."\n"; + echo "Seqn: ".$row['SeqId']." - ".$row['SeqName']."\n"; $sql = "INSERT INTO sequences (id, number, value) VALUES(?,?,?)"; $insert = $sqlite_db->prepare($sql); if($insert === false){ $err= $dbh->errorInfo(); die($err[2]); } @@ -247,7 +193,7 @@ function convert_sequences($mysql_db, $sqlite_db, $min) $query = $mysql_db->query($sqltest); while ($row = $query->fetch_array()) { - echo $row['SeqId']." - ".$row['BookId']."\n"; + echo "BkSq: ".$row['SeqId']." - ".$row['BookId']."\n"; $sql = "INSERT INTO bookseq(id_book, id_seq, number, level) VALUES(?,?,?,?)"; $insert = $sqlite_db->prepare($sql); if($insert === false){ $err= $dbh->errorInfo(); die($err[2]); } @@ -259,123 +205,38 @@ function convert_sequences($mysql_db, $sqlite_db, $min) $sqlite_db->query("commit;"); } -function create_tables($sqlite_db, $date) +function setup_params($sqlite_db, $date, $type) { $sqlite_db->query("begin transaction;"); - $sqlite_db->query(" - CREATE TABLE authors( - id integer primary key, - letter char(1), - search_name varchar(255), - full_name varchar(255), - first_name varchar(128), - middle_name varchar(128), - last_name varchar(128), - number integer, - newid integer, - description text); - "); - - $sqlite_db->query(" - CREATE TABLE books( - id integer not null, - id_author integer, - title varchar(255) not null, - annotation text, - genres text, - id_sequence integer, - deleted boolean, - id_archive integer, - file_name text, - file_size integer, - file_type varchar(20), - md5sum char(32), - created integer, - lang char(2), - year integer, - description text); - "); - - $sqlite_db->query("CREATE TABLE sequences(id integer primary key, number integer, value varchar(255) not null);"); - - $sqlite_db->query("CREATE TABLE bookseq(id_book integer, id_seq integer, number integer, level integer, id_author integer);"); - - $sqlite_db->query("CREATE TABLE genres(id_book integer, id_genre CHAR(2));"); + $code = $date - 20000000; - $sqlite_db->query("CREATE TABLE params(id integer primary key, value integer, text text);"); $sqlite_db->query("DELETE FROM params;"); - $sqlite_db->query("INSERT INTO params(id,text) VALUES (1, 'Flibusta library');"); - $sqlite_db->query("INSERT INTO params(id,value) VALUES (2, 1);"); - $sqlite_db->query("INSERT INTO params(id,text) VALUES (3, 'FLIBUSTA');"); - $sqlite_db->query("INSERT INTO params(id,text) VALUES (11,'flibusta.net');"); - $sqlite_db->query("INSERT INTO params(id,value) VALUES (16, ".$date.");"); + $sqlite_db->query("INSERT INTO params(id,text) VALUES (1, 'Flibusta library');"); + $sqlite_db->query("INSERT INTO params(id,value) VALUES (2, 1);"); + $sqlite_db->query("INSERT INTO params(id,text) VALUES (3, 'FLIBUSTA');"); + $sqlite_db->query("INSERT INTO params(id,text) VALUES (11, 'flibusta.net');"); + $sqlite_db->query("INSERT INTO params(id,text) VALUES (15, '$type');"); + $sqlite_db->query("INSERT INTO params(id,value) VALUES (16, $code);"); $sqlite_db->query("commit;"); } -function create_indexes($sqlite_db) -{ - $sqlite_db->query("begin transaction;"); - - $sqlite_db->query(" - CREATE TABLE archives( - id integer primary key, - file_name varchar(255), - file_path varchar(255), - file_size integer, - file_count integer, - min_id_book integer, - max_id_book integer, - file_type varchar(20), - description text); - "); - - $sqlite_db->query("CREATE TABLE aliases(id_author integer not null, id_alias integer not null);"); - - $sqlite_db->query("CREATE INDEX author_letter ON authors(letter);"); - $sqlite_db->query("CREATE INDEX author_name ON authors(search_name);"); - - $sqlite_db->query("CREATE INDEX book_id ON books(id);"); - $sqlite_db->query("CREATE INDEX book_author ON books(id_author);"); - $sqlite_db->query("CREATE INDEX book_archive ON books(id_archive);"); - $sqlite_db->query("CREATE INDEX book_md5sum ON books(md5sum);"); - $sqlite_db->query("CREATE INDEX book_created ON books(created);"); - - $sqlite_db->query("CREATE INDEX book_file ON archives(file_name);"); - - $sqlite_db->query("CREATE INDEX sequences_name ON sequences(value);"); - - $sqlite_db->query("CREATE INDEX bookseq_book ON bookseq(id_book);"); - $sqlite_db->query("CREATE INDEX bookseq_author ON bookseq(id_author);"); - - $sqlite_db->query("CREATE INDEX aliases_author ON aliases(id_author);"); - $sqlite_db->query("CREATE INDEX aliases_alias ON aliases(id_alias);"); - - $sqlite_db->query("CREATE INDEX genres_book ON genres(id_book);"); - $sqlite_db->query("CREATE INDEX genres_genre ON genres(id_genre);"); - - $sqlite_db->query("commit;"); - - $sqlite_db->query("vacuum;"); -} - function FullImport($mysql_db, $sqlitefile, $date) { $sqlite_db = new PDO('sqlite:'.$sqlitefile); - create_tables($sqlite_db, $date); + create_tables($sqlite_db); + setup_params($sqlite_db, $date, "FULL"); - create_tables($sqlite_db, 0); - convert_genres($mysql_db, $sqlite_db, 0); convert_authors($mysql_db, $sqlite_db, 0); - convert_books($mysql_db, $sqlite_db, 0); - convert_dates($mysql_db, $sqlite_db, 0); convert_seqnames($mysql_db, $sqlite_db, 0); + convert_books($mysql_db, $sqlite_db, 0); convert_sequences($mysql_db, $sqlite_db, 0); + convert_genres($mysql_db, $sqlite_db, 0); + convert_dates($mysql_db, $sqlite_db, 0); + create_indexes($sqlite_db); - - $sqlite_db->query("INSERT INTO params(id,text) VALUES (15, 'FULL');"); } function DeltaImport($mysql_db, $date) @@ -389,14 +250,18 @@ function DeltaImport($mysql_db, $date) $query = $mysql_db->query($sqltest); if ($row = $query->fetch_array()) { $sqlite_db = new PDO('sqlite:'.$sqlitefile); + create_tables($sqlite_db, $date); + setup_params($sqlite_db, $date, "DELTA"); + convert_authors($mysql_db, $sqlite_db, $row['aid']); + convert_seqnames($mysql_db, $sqlite_db, $row['sid']); convert_books($mysql_db, $sqlite_db, $row['bid']); - convert_genres($mysql_db, $sqlite_db, $row['bid']); convert_sequences($mysql_db, $sqlite_db, $row['bid']); - convert_seqnames($mysql_db, $sqlite_db, $row['sid']); + convert_genres($mysql_db, $sqlite_db, $row['bid']); + convert_dates($mysql_db, $sqlite_db, $row['bid']); } - + $mysql_db->query("INSERT INTO myrulib_update(date) VALUES(".$date.")"); $mysql_db->query(" @@ -405,8 +270,6 @@ function DeltaImport($mysql_db, $date) bid=(SELECT MAX(BookId) FROM libbook), sid=(SELECT MAX(SeqId) FROM libseq) WHERE date=$date"); - - $sqlite_db->query("INSERT INTO params(id,text) VALUES (15, 'DELTA');"); } $mysql_srvr = 'localhost'; |