function biblio_update_6024 in Bibliography Module 7
Same name and namespace in other branches
- 6.2 biblio.install \biblio_update_6024()
- 6 biblio.install \biblio_update_6024()
- 7.2 biblio.install \biblio_update_6024()
Add the new field -refereed- on the biblio table.
File
- ./
biblio.install, line 1834
Code
function biblio_update_6024() {
db_add_field('biblio', 'biblio_refereed', array(
'type' => 'varchar',
'length' => '20',
));
/* add the field data for -refereed- on the biblo_fields table
you need to get the last inserted record from biblio_fields and increment it by one
so you don't step on customized fields added via the user online interface */
$sql = 'SELECT fid FROM {biblio_fields} ORDER BY fid DESC';
$lastfid = db_query_range($sql, 0, 1)
->fetchField();
$newfid = $lastfid + 1;
db_query("INSERT INTO {biblio_fields} (fid, name, type, size, maxsize) VALUES\n ({$newfid}, 'biblio_refereed', 'select', 0, 125)");
/*use the same fid and insert an entry in the biblio_field_type_data */
db_query("INSERT INTO {biblio_field_type_data}\n (ftdid, title, hint) VALUES ({$newfid}, 'Refereed Designation', NULL)");
/* get a list of unique tids from the biblio_field_type table. You want to
insert a tid,fid using the new fid for every available tid */
$newsql = "SELECT DISTINCT tid FROM {biblio_field_type} ORDER BY tid DESC";
$tidlist = db_query($newsql);
foreach ($tidlist as $tid) {
$newtid = $tid->tid;
db_query('INSERT INTO {biblio_field_type}
(tid, fid, ftdid, cust_tdid, common, autocomplete, required, weight, visible)
VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %d)', $newtid, $newfid, $newfid, $newfid, 1, 1, 0, 1, 1);
}
}