예제 #1
0
 /**
  * @return int
  */
 public static function lastInsertId()
 {
     return (int) self::$conn->lastInsertId();
 }
예제 #2
0
    $logger->addInfo("Found no new comments to import, exiting early");
    exit;
}
$logger->addInfo("Found {$commentCount} comments to import, starting from ID: {$lastBatchLimit}.");
foreach ($commentBatch as $comment) {
    $query = "\n        SELECT `id` FROM `comment_service`.`commenter`\n        WHERE `name` = :name AND `email` = :email AND `website` = :website\n        LIMIT 1";
    $bindings = ['name' => $comment['name'], 'email' => $comment['email'], 'website' => $comment['url']];
    $commenterId = $commentDB->fetchValue($query, $bindings);
    if (!$commenterId) {
        $query = "\n            INSERT INTO `comment_service`.`commenter` (`name`, `email`, `website`, `is_trusted`)\n            VALUES (:name, :email, :website, :is_trusted)";
        $bindings = ['name' => $comment['name'], 'email' => $comment['email'], 'website' => $comment['url'], 'is_trusted' => $comment['trusted']];
        if (!$commentDB->perform($query, $bindings)) {
            $logger->addError('Could not insert commenter - exiting out');
            exit;
        }
        $commenterId = $commentDB->lastInsertId();
    }
    $query = "\n        INSERT INTO `comment_service`.`comment_body` (`body`)\n        VALUES (:body)";
    $bindings = ['body' => $comment['body']];
    if (!$commentDB->perform($query, $bindings)) {
        $logger->addError('Could not insert comment_body - exiting out');
        exit;
    }
    $bodyId = $commentDB->lastInsertId();
    $domain = $comment['site'] == 2 ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com';
    $query = "\n        SELECT `id` FROM `comment_service`.`comment_domain`\n        WHERE `domain` = :domain LIMIT 1";
    $bindings = ['domain' => $domain];
    $domainId = $commentDB->fetchValue($query, $bindings);
    if (!$domainId) {
        $query = "\n            INSERT INTO `comment_service`.`comment_domain` (`domain`)\n            VALUES (:domain)";
        $bindings = ['domain' => $domain];