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!!
Importing content directly into database?
-
calguy1000
- Support Guru

- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Importing content directly into database?
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.
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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
sioux
Re: Importing content directly into database?
Hi Calguy,
Hmmm - with my limited skills, maybe I'll just say no
Hmmm - with my limited skills, maybe I'll just say no
Re: Importing content directly into database?
In which module do you want to import all these data ?
-
samurai
Re: Importing content directly into database?
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
Now I only need to enclose them in and probably it will work 
Any help would be much appreciated.
Geo
I wrote a little pseudo code - limited php skills
"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
Any help would be much appreciated.
Geo
-
ganeshXL
Re: Importing content directly into database?
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.calguy1000 wrote:
d) reformat the data into the appropriate sql statements, i.e: alot of "INSERT INTO..." statements
(this is usually quite painful)
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.

