import_process
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
import_process [2019/03/24 22:04] – steve | import_process [2019/03/24 22:08] – steve | ||
---|---|---|---|
Line 12: | Line 12: | ||
That's it! | That's it! | ||
+ | |||
+ | Doing some code dumps here: | ||
+ | |||
+ | < | ||
+ | <script src=' | ||
+ | </ | ||
+ | |||
+ | AJAX: | ||
+ | |||
+ | < | ||
+ | <?php | ||
+ | |||
+ | error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED); | ||
+ | ini_set(' | ||
+ | |||
+ | $insert = false; | ||
+ | $update = true; | ||
+ | |||
+ | if($insert) | ||
+ | $pdo_dsn = " | ||
+ | elseif($update) | ||
+ | $pdo_dsn = " | ||
+ | else | ||
+ | exit; | ||
+ | |||
+ | $legacy_db = new PDO(" | ||
+ | $legacy_db-> | ||
+ | |||
+ | $update_db = new PDO(" | ||
+ | $update_db-> | ||
+ | |||
+ | // Sample queries | ||
+ | |||
+ | // getOne(): | ||
+ | /* | ||
+ | $foo = $db-> | ||
+ | $bar = $foo-> | ||
+ | var_dump($bar); | ||
+ | |||
+ | // getCol(): | ||
+ | $foo = $db-> | ||
+ | $bar = $foo-> | ||
+ | |||
+ | // getAll(): | ||
+ | $foo = $db-> | ||
+ | $bar = $foo-> | ||
+ | print_r($bar); | ||
+ | |||
+ | // getRow(): | ||
+ | $foo = $db-> | ||
+ | $bar = current($foo-> | ||
+ | print_r($bar); | ||
+ | */ | ||
+ | |||
+ | try { | ||
+ | $db = new PDO($pdo_dsn); | ||
+ | $db-> | ||
+ | } catch (PDOException $e) { | ||
+ | echo "* Error!: " | ||
+ | exit(1); | ||
+ | } | ||
+ | |||
+ | extract($_POST); | ||
+ | |||
+ | $bcv = htmlentities($bcv); | ||
+ | $bcv = str_replace("& | ||
+ | $bcv = str_replace("& | ||
+ | |||
+ | $text = htmlentities($text); | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | $text = str_replace("& | ||
+ | |||
+ | // Legacy has ' | ||
+ | $bcv = str_replace(" | ||
+ | |||
+ | // " | ||
+ | $bcv = str_replace(" | ||
+ | |||
+ | if($bcv == " | ||
+ | $text = str_replace(" | ||
+ | |||
+ | if($update) { | ||
+ | |||
+ | $q_bcv = $db-> | ||
+ | $q_scripture_text = $db-> | ||
+ | |||
+ | $sql = " | ||
+ | |||
+ | $rs = $legacy_db-> | ||
+ | $rows = $rs-> | ||
+ | |||
+ | if(count($rows) == 0) { | ||
+ | error_log(" | ||
+ | exit; | ||
+ | } | ||
+ | |||
+ | $row = current($rows); | ||
+ | |||
+ | $legacy_id = $row[' | ||
+ | $legacy_text = $row[' | ||
+ | |||
+ | if($legacy_text != $text) { | ||
+ | $sql = " | ||
+ | file_put_contents(" | ||
+ | // $update_db-> | ||
+ | error_log($bcv); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ |
import_process.txt · Last modified: by steve