PDA

View Full Version : Add Category MySQL Query


insidedesign
03-17-2006, 12:56 AM
Could anyone provide MySQL Query code to add categories manually? I would like to make a text file where I can just copy and paste the query into all my PHPLD installs so I do not have to add them manually. I am interested in adding about 7 main cats with about 14 specific cats in each of those 7.

How would I structure the MySQL query to carry that out? And what table would I execute it on?

Neticus
03-17-2006, 02:36 AM
Are these the directories in your link? looks like you've already populated. Unless your on about an empty one.
Also it may help someone help by stating which version you're using.

-

insidedesign
03-17-2006, 02:44 AM
Well, I don't exect someone to type the 100+ cats I want to add. I am just looking for some example syntax I could use to create the real thing.

As for the version, I am using: v2

Neticus
03-17-2006, 03:14 AM
The following is a template for 7 main cats with 14 sub cats in each.
in total 114 cats. Im hoping you're able to see a pattern and adjust as necessary.



From what i understand both pld_category_seq and pld_category have to be empty first before you sql query.


INSERT INTO `pld_category_seq` VALUES (114);
INSERT INTO `pld_category` VALUES (1, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (2, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (3, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (4, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (5, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (6, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (7, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (8, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (9, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (10, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (11, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (12, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (13, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (14, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (15, 'Sub Category', 'Sub_category', '', 1, 2, '0000-00-00 00:00:00', 1);


INSERT INTO `pld_category` VALUES (16, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (17, 'Sub Category', 'Sub_category', '', 16, 2, '0000-00-00 00:00:00', 1);
repeat above sub cat to 30

INSERT INTO `pld_category` VALUES (31, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (32, 'Sub Category', 'Sub_category', '', 31, 2, '0000-00-00 00:00:00', 1);
repeat above sub cat to 45

INSERT INTO `pld_category` VALUES (46, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (47, 'Sub Category', 'Sub_category', '', 46, 2, '0000-00-00 00:00:00', 1);
repeat above sub cat to 60

INSERT INTO `pld_category` VALUES (61, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (62, 'Sub Category', 'Sub_category', '', 61, 2, '0000-00-00 00:00:00', 1);
repeat above sub cat to 75

INSERT INTO `pld_category` VALUES (76, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (77, 'Sub Category', 'Sub_category', '', 76, 2, '0000-00-00 00:00:00', 1);
repeat above sub cat to 90

INSERT INTO `pld_category` VALUES (91, 'Main Category Title', 'Main_Category_Title', '', 0, 2, '0000-00-00 00:00:00', 1);
INSERT INTO `pld_category` VALUES (92, 'Sub Category', 'Sub_category', '', 91, 2, '0000-00-00 00:00:00', 1);
repeat above sub cat to 114


Hope this helps.
Net.

insidedesign
03-17-2006, 03:55 AM
Great thanks for the help! I also appreciate the extra effort with the bold tags!

anon
03-17-2006, 08:17 AM
Content visible to registered users only.

very important to note which VERSION he mentions.
(i know you stated you're on v2, which he suggested. just other people don't tend to not read up like they should ;) )

diff versions = diff db's, which in turn, obviously mean different insert columns.

Neticus
03-18-2006, 08:10 PM
If you are having problems.

I have just realised that the template used was taken from a cats only mod which is not compatible with the
current version of v2 (although it was with the version before), extra rows have been added since.

Net.

insidedesign
03-19-2006, 01:15 AM
Thanks for the followup. But I just decided to export the cat tables and just import them into the other dbs. Thanks!

bronzy
09-16-2006, 02:22 AM
Can I use this to import my cats.

Content visible to registered users only.

Boby
09-16-2006, 02:27 AM
Please, try to use the admin panel of your directory as much as possible and don't get into trouble with regular SQL importing unless you know what you are doing.

bronzy
09-16-2006, 02:32 AM
yeah but I dont know how to add subcategories in admin panel. I really dont understand that symbolic cat. Do you mind giving me an example of how to add? pretty please

Boby
09-16-2006, 02:37 AM
Ok, let me try... :)

When you start, you add first lever categories with the parent TOP. These are the categories you will have on the main page.

Then you can add other categories that have the parent category for example "Arts", these are subcategs for you main "Arts" categ. You can also add sub...sub....sub...categs :)

Don't bother first with symbolic categories, try to understand the basic category structure first.

A symbolic category is nothing more than a placeholder in one category that will redirect to it's "main" category when clicked.

bronzy
09-16-2006, 02:45 AM
ok great I'll give it a go. thanks again