Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Simple approach to auto-create DB table without need to connect/import in DB Server..

I was writing a very simple PHP Class to handle comments for a web-shop, and figured it would be much better for me, and the end-user to setup the script - Without need to connect to MySQL Server and manually import database structure. Instead just load the Class and done.

https://pastebin.com/sUnvhUCz
The script triggers forum security, so can not post it directly.
(Dec 16, 2022 01:26 PM)Shellcode™ Wrote:  I was writing a very simple PHP Class to handle comments for a web-shop, and figured it would be much better for me, and the end-user to setup the script - Without need to connect to MySQL Server and manually import database structure. Instead just load the Class and done.

https://pastebin.com/sUnvhUCz
The script triggers forum security, so can not post it directly.

Did we travel back in time? Who uses PHP and the original pastebin? Can't say I clicked on that link. Last time I checked there were only crawlers and adds on that site. I'm not sure if it's safe
Microsoft Word is the best IDE for programming
(Dec 16, 2022 03:57 PM)step1step2 Wrote:  Did we travel back in time? Who uses PHP and the original pastebin? Can't say I clicked on that link. Last time I checked there were only crawlers and adds on that site. I'm not sure if it's safe

- Did we travel back in time?

No, pastebin is still #1 most popular code-sharing platform. Not sure what do you mean by "Ads" on the site - If you are using Ad Blocker, there are no ads. I thought you are a developer, you should know stuff like this.

Crawlers? Yes, there are crawler scripts available around, but they only can access publicly listed pastes, not privately listed like this. Not really sure why that is a problem for you also, 3rd party crawlers wont affect you looking at a script on pastebin. Besides there are crawlers for most of other pastebin's also.

- Who uses PHP?
It is used by back-end developers to write server-side code. Saying this would be saying the same as "Who uses HTML" lol!
This is definitely something you could do, but at the same time you could just use a mysqldump sql file to import into a fresh db with a new user. If you set it up, you could do this without taking the data with you or doing it on a per-table basis. Either way, I would recommend using individual table .sql files for creation instead of doing it inline with PHP. How will you handle table relationships, triggers, etc? You can, but it's easier with standard mysql import/export funcs
Database migration tools were invented to solve this problem. Usually frameworks like Laravel, Django and Rails have built-in support for doing just that. They also have mechanisms to revert the migration in case things go wrong. In my experience, it's easiest to have them as a CI step close to the application deployment.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Javascript]  by CinderGhoulNov 28, 2021 08:13 AM 2 180 Nov 28, 2021 08:13 AM
Last Post: CinderGhoul
[PHP] by DivineProgrammingFeb 15, 2020 01:56 PM 6 191 Feb 15, 2020 01:56 PM
Last Post: DivineProgramming
[PHP] by RayGenWurmMar 4, 2019 06:53 PM 7 242 Mar 4, 2019 06:53 PM
Last Post: ChaoticHaze