Skip to content

Instantly share code, notes, and snippets.

@technolize
Created November 21, 2014 09:55
Show Gist options
  • Save technolize/f8b790589a9a1cc6b970 to your computer and use it in GitHub Desktop.
Save technolize/f8b790589a9a1cc6b970 to your computer and use it in GitHub Desktop.
<?php
$connection = $this->getContainer()->get('database_connection');
$params = $connection->getParams(); // getParameters じゃないのがちょっと…
$pdo = new \PDO(...);
$pdo->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
$query = '...';
$stmt = $pdo->prepare($query);
$stmt->execute();
while ($row = $stmt->fetch(\PDO::FETCH_OBJ))
{
// データ加工の処理とか
$connection->insert('...', $data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment