Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert Drupal Audio content type to CCK Filefield
mysql_select_db($database) or die( "Unable to select database");
// Query all the audio nodes.
$q = <<<SQL
SELECT * FROM node n
LEFT JOIN audio_file af on af.vid = n.vid
LEFT JOIN node_revisions nr on nr.vid = n.vid
WHERE type = 'audio'
$result = mysql_query($q);
print '<pre>';
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$insert_file = sprintf("INSERT INTO `files` (`uid`, `filename`, `filepath`, `filemime`, `filesize`, `status`, `timestamp`) VALUES (%d, '%s', '%s', '%s', %d, 1, %d )",
//print $insert_file . "\n";
$temp = mysql_query($insert_file);
$fid = mysql_insert_id();
// INSERT INTO content_type_podcast
$insert_pod = sprintf("INSERT INTO `content_type_podcast` (`vid`, `nid`, `field_mp3_file_fid`, `field_mp3_file_list`) VALUES (%d, %d, %d, 1)",
print $insert_pod . "\n";
$temp = mysql_query($insert_pod);
// Update node table
$q = "UPDATE `node` n SET `type` = 'podcast' WHERE `type` = 'audio'";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.