function dynamic_background_blog_update_7000 in Dynamic Background 7.2
Update stored data to use the new database tables.
File
- modules/
dynamic_background_blog/ dynamic_background_blog.install, line 57 - Installs the database scheme and handles install and uninstall of the module.
Code
function dynamic_background_blog_update_7000() {
$query = db_select('dynamic_background_blog', 'dbb');
$result = $query
->fields('dbb', array(
'uid',
'image_id',
))
->execute();
// Load the old stored image, as the old node extension used the array index
// and not the fid (doh).
$images = variable_get('dynamic_background_images', array());
while ($row = $result
->fetchObject()) {
db_insert('dynamic_background_usage')
->fields(array(
'fid' => $images[$row->image_id]['fid'],
'type' => 'blog',
'data' => $row->uid,
))
->execute();
}
}