How to export KB categories and keep the structure?

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
deserteagle369
Posts: 94
Joined: Wed Feb 29, 2012 2:00 am

How to export KB categories and keep the structure?

Post 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.
Eagle
Life is a journey.
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

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

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
deserteagle369
Posts: 94
Joined: Wed Feb 29, 2012 2:00 am

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

Post 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.
Eagle
Life is a journey.
Post Reply