Script to create posts from txt or SQL file direct to phpBB SQL

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Wed Sep 04, 2019 7:07 pm

Hi,
I'd like to run a script that will create posts on my phpBB from a source file.
I have an SQL database with over a million rows. The DB has 6 columns. I want each row to be a post under one of my forums. Each post title would be a column a specify, etc.

There an easy way to achieve my request?

User avatar
3Di
Former Team Member
Posts: 14088
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by 3Di » Wed Sep 04, 2019 7:10 pm

You may ask int the "custom coding" forum, or in the "wanted!" one if you wish to get it as a custom job.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Wed Sep 04, 2019 7:12 pm

3Di wrote:
Wed Sep 04, 2019 7:10 pm
You may ask int the "custom coding" forum, or in the "wanted!" one if you wish to get it as a custom job.
Gotcha. Would you be able to move this post for me there? Else I'll make new thread, thanks
Last edited by KevC on Wed Sep 04, 2019 7:15 pm, edited 1 time in total.
Reason: moved to custom coding

User avatar
3Di
Former Team Member
Posts: 14088
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by 3Di » Wed Sep 04, 2019 7:15 pm

I have reported it, should be moved once a moderator will see it.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Thu Sep 05, 2019 1:44 pm

Thanks....

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Thu Sep 05, 2019 3:36 pm

Going to simplify this....I have a file with names (around 3 million) and i want to create posts with them based on the names for topic and same for post.

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Thu Sep 05, 2019 6:37 pm

Well I found this: viewtopic.php?f=65&t=2115251#p12923598

Gonna stay away actually since its old and I dont see anyone trying it on the latest version

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Fri Sep 06, 2019 6:52 pm

I did an export of current posts from phpBB into a CSV file and I see these fields. If I build an xml similarly and import it, shouldn't it work the same?
If I did, could I leave post/topic ID's blank for the system to generate? What would I need to put in for post checksum?

Thanks

post_id
topic_id
forum_id
poster_id
icon_id
poster_ip
post_time post_reported
enable_bbcode
enable_smilies
enable_magic_url
enable_sig
post_username post_subject
post_text post_checksum post_attachment
bbcode_bitfield bbcode_uid
post_postcount post_edit_time post_edit_reason
post_edit_user post_edit_count
post_edit_locked
post_visibility
post_delete_time
post_delete_reason
post_delete_user
post_modified sfs_reported

User avatar
canonknipser
Registered User
Posts: 2063
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by canonknipser » Fri Sep 06, 2019 7:06 pm

It's not that easy to just import some rows into a single table to create working board content.
Most of the tables in phpBB are connected by application logic, eg, posts have references to topics, users and forums. Users have a post count. Topics have a post count and much more ...
All those references must be created in a correct way.
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Mon Sep 09, 2019 12:44 am

Makes sense...

Well I didn't realize this would be a bigger undertaking (I thought might be a post automater for such a situation). Any suggestions otherwise? I guess I would pay someone to help with this but not sure what it may cost

User avatar
david63
Registered User
Posts: 16417
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by david63 » Mon Sep 09, 2019 7:34 am

urzh wrote:
Thu Sep 05, 2019 6:37 pm
Well I found this: viewtopic.php?f=65&t=2115251#p12923598

Gonna stay away actually since its old and I dont see anyone trying it on the latest version
Don't go anywhere near that. It was written for phpBB 3.0 and many things have changed since then.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
Ger
Recognised Extension Developer
Posts: 1870
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by Ger » Mon Sep 09, 2019 9:46 am

Basically I'd loop through your data and call submit_post() for each row. For an example, look at https://github.com/GerB/cmbb/blob/4b143 ... #L282-L314
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
Ger
Recognised Extension Developer
Posts: 1870
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by Ger » Thu Sep 12, 2019 7:00 am

As requested; the code to import per line from a .txt file.

This code contains a section that handles with old Mac-style line endings (\r), converting them to whatever line ending style your server has. It shoud also cope with converting Windows style line endings to UNIX, etc. but that's untested.

It's a simple, one-file script that has to be called once, and once only. Only useable for admins/founders and should be deleted after use.

@urzh has confirmed this working as expected.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
vivday
Registered User
Posts: 31
Joined: Sat Jun 29, 2019 6:28 am

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by vivday » Fri Sep 13, 2019 5:46 pm

Ger wrote:
Thu Sep 12, 2019 7:00 am
As requested;
the code to import per line from a .txt file


It's a simple, one-file script that has to be called once, and once only. Only useable for admins/founders and should be deleted after use.

@urzh has confirmed this working as expected.
The script doesn't seem to have defined the ID of the Topic to which the posts need to be added.
The opposite of a profound truth may very well be another profound truth.
~~Niels Bohr

urzh
Registered User
Posts: 91
Joined: Mon Aug 05, 2019 1:51 pm
Name: Robert

Re: Script to create posts from txt or SQL file direct to phpBB SQL

Post by urzh » Fri Sep 13, 2019 6:39 pm

vivday wrote:
Fri Sep 13, 2019 5:46 pm

The script doesn't seem to have defined the ID of the Topic to which the posts need to be added.

it does, try it

Post Reply

Return to “phpBB Custom Coding”