Page 1 of 1
Importing content directly into database?
Posted: Tue Mar 14, 2006 8:58 pm
by sioux
As what I know about databases could be written on the back of a postage stamp with room to spare please excuse me if this is a silly question BUT, I have someone building a site using cmsms, who has 9000 (yes 9000) question and answer pages to put on it. Unsurprisingly he wants to know if they can be uploaded directly into the database?
I'm guessing no, but as it would save him hours of work I thought I'd ask just in case!!
Re: Importing content directly into database?
Posted: Tue Mar 14, 2006 9:06 pm
by calguy1000
The answer is "Maybe"
It depends on how he intends to display these:
each as a separate page
or
in a faq module
or
in phpsurveyor or something
either way, the best method is to:
a) create a sample installation
b) learn the format of the table(s) (hopefully only one) that have to be massaged
c) backup the database (to be safe)
d) reformat the data into the appropriate sql statements, i.e: alot of "INSERT INTO..." statements
(this is usually quite painful)
e) do the sql import
if it fails
restore the database
repeat steps d, and e until everything is happy.
Re: Importing content directly into database?
Posted: Tue Mar 14, 2006 9:13 pm
by sioux
Hi Calguy,
Hmmm - with my limited skills, maybe I'll just say no

Re: Importing content directly into database?
Posted: Thu Mar 16, 2006 8:45 am
by fredt
In which module do you want to import all these data ?
Re: Importing content directly into database?
Posted: Mon Mar 27, 2006 5:06 pm
by samurai
I was searching the forums and I couldn't find anything helpful

. I need as well to import a few hundreds text files - they will be separate pages under "Home", then later an editor will move them in the required categories.
I wrote a little pseudo code - limited php skills

, maybe someone who is familiar with the tables can check this out, please let me know if I'm missing something. Server has CMSMS vers 12.1.
"Home" - has
content_id = 15
template_id = 4
owner_id and
last_modified_by = 1
Code: Select all
0. $counter = 1
1. get filename
2. fetch file content = $CONTENT
3. get id from [i]content_seq[/i]
4. $page_id=++id
5. update id with $page_id
6. insert into [i]content_props[/i] "$page_id", "string", "content_en", '','','', $CONTENT, '',''
7. insert into [i]content[/i] "$page_id", filename, "content", 1, 15, 4, $counter, 00001.0000$counter, 0, $filename, $fi_le_na_me, 1,'',"html",1,1,15.$page_id, "content_en" ,'','','','',1, datetime,datetime
8. ++$counter goto 1
Now I only need to enclose them in and probably it will work
Any help would be much appreciated.
Geo
Re: Importing content directly into database?
Posted: Sat Aug 05, 2006 4:23 pm
by ganeshXL
calguy1000 wrote:
d) reformat the data into the appropriate sql statements, i.e: alot of "INSERT INTO..." statements
(this is usually quite painful)
Just on a sidenote, you can make your life easier with using MS-Excel (or some similar product like Open Office Calc) for that kinda stuff.
Separate the query into blocks (columns), and just alter the fields where necessary (e.g. use fomulas). Use one extra column just for the raw content. Then, if everything looks fine, copy all that jazz into a good text-editor (e.g. EditPlus), replace tab-characters with a space, and you should be fine.