I have created a custom CCK form to use to upload content into my drupal website. How can I find out what MYSQL INSERT command is being used after I hit 'submit' on the form to post it?
The database is on my local harddrive and so is the content I'm aggregating and inserting. It's going to be a helluva lot faster if I just create a php script that mimics the columns in the table, uploads in one batch database insert, and bypasses the form altogether.
I've read a bit about hook_schema, and drupal write record, but it's a bit confusing. Any thoughts on how to approach dissecting this to recreate the insert would be appreciated. My form has a TITLE, BODY, two custom cck fields, and an image upload using filefield and imageapi.
If you really wanted to see the form it's at Gastonia.com, but you'd have to create a quick test account to look at it. otherwise, it's located at gastonia.com/post/for-sale
Thanks,
Blue
Comments
You might consider using the
You might consider using the node import module.
Well, node import isn't the best for me
I have a collection of articles and accompanying photos that I've written in a program like MS Word and saved as a text file (files saves separately, not inside the document). Initially, I created a custom CCK form that I used to simply copy the title, body, and upload the photos.
There are 1000s of articles and accompanying photos. My form works great, but good God it's taking hours and hours to do it manually. Node import didn't work for me.
If there was a way I could stop the form from actually posting, and instead print out the INSERT query (or array of queries), instead of executing it, then I could model my custom PHP script to aggregate my data and upload it directly to the database, completely bypassing my custom form.
This would take seconds rather than the, literally, MONTHS it's going to take to do them one by one.
Any thoughts on another way to approach this?
The photos will present a
The photos will present a challenge so I will ignore that for a moment.
Given you can export the data and import it, you can use code the follows this form
Images are a bigger challenge and the details depend on how you are bring them over and how you are storing them.
if you are able to get data
if you are able to get data in xml or csv file you can use feeds module with feeds image grabber to save images and nodes into those tables at one go or on the cron run. Thats the easiest method i can think of, however if you love coding you can use node_save($node) function as suggested above or use drupal_execute to import them.
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form