Skip to content

@shanestillwell /convert.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Convert Drupal Audio content type to CCK Filefield
<?php
$user="USERNAME";
$password="PASSWORD";
$database="DATABASE";
mysql_connect('localhost',$user,$password);
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'
SQL;
$result = mysql_query($q);
print '<pre>';
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
//print_r($row);
$insert_file = sprintf("INSERT INTO `files` (`uid`, `filename`, `filepath`, `filemime`, `filesize`, `status`, `timestamp`) VALUES (%d, '%s', '%s', '%s', %d, 1, %d )",
$row['uid'],
$row['filename'],
$row['filepath'],
$row['filemime'],
$row['filesize'],
$row['timestamp']
);
//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)",
$row['vid'],
$row['nid'],
$fid
);
print $insert_pod . "\n";
$temp = mysql_query($insert_pod);
}
// Update node table
$q = "UPDATE `node` n SET `type` = 'podcast' WHERE `type` = 'audio'";
mysql_query($q);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.