). $results = db_query(" SELECT n.nid, nr.vid FROM {node} n LEFT JOIN {node_revisions} nr ON (nr.nid = n.nid) WHERE n.type = 'flexinode-1' ORDER BY n.nid" ); while ($result = db_fetch_object($results)) { // now that we know the nid of one of our Flexinode node types, we grab // all its data from the flexinode_data table. you'll need to know what // type of data you're grabbing! if it's textual_data, the numeric_data // column has the input format for importing to CCK. serialized_data will // always need custom code to import properly. note also that we're only // grabbing data for the field IDs that are related to this node type. $fresults = db_query(' SELECT * FROM {flexinode_data} WHERE nid = %d AND field_id IN (2, 3, 4)', $result->nid); // shorthand. lower. $flexidata = array(); while ($fresult = db_fetch_object($fresults)) { $flexidata[$fresult->field_id] = $fresult; } // are we using the teaser or body? if we're not, wipe them out // here because CCK doesn't need them (and we don't want Flexinode's // created content in there). If we ARE going to use them, this is // where we'd set their values from the raw Flexinode data. db_query("UPDATE {node_revisions} SET teaser = '', body = '', format = '0' WHERE nid = %d", $result->nid); // and now take all the Flexinode field types and map them to our new // CCK table. again, this presumes that you know what the table structure // of your CCK node type is. this is not something I am willing to show. db_query(" INSERT INTO {node_nameofCCKtype} SET vid = %d, nid = %d, field_synopsis_value = '%s', field_synopsis_format = %d, field_transcript_value = '%s', field_transcript_format = %d, field_audio_file_value = '%s'", $result->vid, $result->nid, $flexidata[2]->textual_data, $flexidata[2]->numeric_data, $flexidata[3]->textual_data, $flexidata[3]->numeric_data, $flexidata[4]->textual_data ); // with our CCK table filled in, we'll now reset the // name of the node type in the master node table. db_query('UPDATE {node} SET type = "nameofCCKtype" WHERE nid = %d', $result->nid); // if you've a ton of nodes to convert, you're either going to run up against // PHP's memory_limit (nothing you can do about that save for increasing it) // or the browser is going to get bored with waiting. we'll print a dot to // keep the browser awake, and send it immediately after a node is converted. print ". "; flush(); ob_flush(); // so the browser doesn't time out. } // let CCK recreate its own caches for the node. db_query('DELETE FROM {cache}'); ?>