function photos_update_4 in Album Photos 6.2
File
- ./
photos.install, line 246
Code
function photos_update_4() {
$ret = array();
$result = db_query('SELECT fid, nid FROM {x_image} ORDER BY fid DESC');
while ($file = db_fetch_object($result)) {
if ($file->nid) {
db_query('INSERT INTO {x_node} (fid, nid) VALUES (%d, %d)', $file->fid, $file->nid);
}
}
db_drop_field($ret, 'x_image', 'nid');
db_change_field($ret, 'x_image', 'num', 'comcount', array(
'type' => 'int',
'not null' => TRUE,
));
db_change_field($ret, 'x_image', 'uid', 'exif', array(
'type' => 'int',
'size' => 'tiny',
'length' => 1,
'default' => 0,
));
db_add_index($ret, 'x_image', 'comcount', array(
'comcount',
));
db_add_index($ret, 'x_image', 'wid', array(
'wid',
));
$schema['cache_photos'] = drupal_get_schema_unprocessed('system', 'cache');
db_create_table($ret, 'cache_photos', $schema['cache_photos']);
$result = db_query('SELECT f.fid, f.filemime FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid ORDER BY f.fid ASC');
while ($image = db_fetch_object($result)) {
db_query('UPDATE {x_image} SET comcount = (SELECT COUNT(fid) FROM {x_vote} WHERE fid = %d), exif = %d WHERE fid = %d', $image->fid, $image->filemie == 'image/jpeg' ? 1 : 0, $image->fid);
}
return $ret;
}