import
[web.mtrack] / schema / 1.php
1 <?php # vim:ts=2:sw=2:et:
2 # Convert attachments so that a copy of blob lives in the db
3
4 echo "Migrating attachments\n";
5 $q = $db->prepare('update attachments set payload = ? where hash = ?');
6
7 foreach ($db->query('select hash from attachments')->fetchAll() as $row) {
8   $path = MTrackAttachment::local_path($row['hash']);
9   $fp = fopen($path, 'rb');
10   $q->bindValue(1, $fp, PDO::PARAM_LOB);
11   $q->bindValue(2, $row['hash']);
12   $q->execute();
13   fclose($fp);
14   $fp = null;
15 }
16