00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 $installer = $this;
00028
00029
00030 $installer->startSetup();
00031
00032 $installer->getConnection()->addColumn($installer->getTable('downloadable/link_purchased_item'), 'link_hash', "varchar(255) NOT NULL default '' AFTER `product_id`");
00033
00034 $installer->getConnection()->addKey($installer->getTable('downloadable/link_purchased_item'), 'DOWNLOADALBE_LINK_HASH', 'link_hash');
00035
00036 $select = $installer->getConnection()->select()
00037 ->from($installer->getTable('downloadable/link_purchased_item'), array(
00038 'item_id',
00039 'purchased_id',
00040 'order_item_id',
00041 'product_id'
00042 ));
00043 $result = $installer->getConnection()->fetchAll($select);
00044
00045 foreach ($result as $row) {
00046 $installer->getConnection()->update(
00047 $installer->getTable('downloadable/link_purchased_item'),
00048 array('link_hash' => strtr(base64_encode(microtime() . $row['purchased_id'] . $row['order_item_id'] . $row['product_id']), '+/=', '-_,')),
00049 $installer->getConnection()->quoteInto('item_id = ?', $row['item_id'])
00050 );
00051 }
00052
00053 $installer->endSetup();