function fivestar_comment_update_5100 in Fivestar 5
Add vote_id column to the fivestar_comment table. This update will only be run when upgrading to fivestar schema 5102.
1 call to fivestar_comment_update_5100()
- fivestar_update_5702 in ./
fivestar.install - Move comment support to a separate module.
File
- ./
fivestar_comment.install, line 42 - Installation file for Fivestar Comment module.
Code
function fivestar_comment_update_5100() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {fivestar_comment} ADD vote_id int(10) UNSIGNED NOT NULL DEFAULT '0' AFTER cid");
$ret[] = update_sql("ALTER TABLE {fivestar_comment} ADD INDEX vote_id (vote_id)");
break;
case 'pgsql':
$ret[] = update_sql("ALTER TABLE {fivestar_comment} ADD vote_id integer NOT NULL DEFAULT '0'");
$ret[] = update_sql("CREATE INDEX {fivestar_comment}_vote_id_idx ON {fivestar_comment} (vote_id)");
break;
}
$comments = db_query('SELECT fc.cid, fc.value, v.vote_id FROM {fivestar_comment} fc INNER JOIN {comments} c ON fc.cid = c.cid INNER JOIN {votingapi_vote} v ON fc.value = v.value AND c.nid = v.content_id AND c.uid = v.uid WHERE v.tag = "vote" AND v.value_type = "percent" AND v.content_type = "node"');
while ($comment = db_fetch_object($comments)) {
db_query('UPDATE {fivestar_comment} SET vote_id = %d WHERE cid = %d', $comment->vote_id, $comment->cid);
}
return $ret;
}