Page 1 of 1

How to export KB categories and keep the structure?

Posted: Tue Nov 06, 2012 6:52 am
by deserteagle369
Script URL:
Version of script:
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

I want to export kb articles to csv or xls to do more analysis, but the kb categories export without the parent-child relation, I want the export result like below:

id--category--------------------------------------subject-----------content
1 hardware:server:motherboard:PCI slot Slot damaged Replace it successfully.
2 software:OS:windows xp sp3:boot Cannot boot Reinstall solve it.

that mean, add the parent category in front of category if it's not top category.

anyone has idea how to do it with sql query?

thx.

Re: How to export KB categories and keep the structure?

Posted: Tue Nov 06, 2012 3:36 pm
by Klemen
Rather than using a single query, your best bet is to first get a list of all categories, create a variable with parent/child structure for each category then get a list of articles and replace category ID with the structure variable.

Re: How to export KB categories and keep the structure?

Posted: Wed Nov 07, 2012 12:50 am
by deserteagle369
Because the categories do not change often, I create a table and import the data in it, like below:
table:hesk_pseries
id-------name
1 hardware:server:motherboard
2 software:OS:windows xp sp3:boot

my problem is how to do the query to get the category name, I tried:

$query = 'SELECT `hesk_kb_articles`.`id` AS "ID", `hesk_pseries`.`name` AS "Category", `hesk_kb_articles`.`subject` AS "Subject",`hesk_kb_articles`.`content` AS "Content",`hesk_kb_articles`.`dt` AS "Date Created", `hesk_kb_articles`.`rating` AS "rating", `hesk_kb_articles`.`votes` AS "votes",`hesk_users`.`name` AS "author", `hesk_kb_articles`.`views` AS "views", `hesk_kb_type`.`name` AS "type"

FROM hesk_kb_articles, hesk_kb_categories, hesk_users, hesk_kb_type,hesk_pseries

WHERE ( (DATE(`dt`) BETWEEN \'' . $date_from . '\' AND \'' . $date_to . '\') and

hesk_kb_categories.id = hesk_kb_articles.catid

AND hesk_users.id = hesk_kb_articles.author

AND hesk_kb_type.id = hesk_kb_articles.type

AND hesk_pseries.name like hesk_kb_categories.name

) order by id asc';

it can't works.