CodeIgniter Forums
Create MySQL Tables without using Database Forge Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Create MySQL Tables without using Database Forge Class (/showthread.php?tid=80399)



Create MySQL Tables without using Database Forge Class - josh2112o - 10-27-2021

Hi,
I am wondering is it possible to execute the raw MySQL CREATE TABLE commands with all columns and accompanying definitions in CodeIgniter 4 instead of using the Database Forge Class?
I am parsing a special .fxl file (which is structured quite similar to an .xml file) and using all the information within the file to create tables with columns and definitions.
In my specific case, building up the raw MySQL queries into the complete query string would be better.


RE: Create MySQL Tables without using Database Forge Class - josh2112o - 10-27-2021

(10-27-2021, 01:40 PM)josh2112o Wrote: Hi,
I am wondering is it possible to execute the raw MySQL CREATE TABLE commands with all columns and accompanying definitions in CodeIgniter 4 instead of using the Database Forge Class?
I am parsing a special .fxl file (which is structured quite similar to an .xml file) and using all the information within the file to create tables with columns and definitions.
In my specific case, building up the raw MySQL queries into the complete query string would be better.
I guess I should have looked better before posting the question here but it looks like I can use the $db connection in a model and run the CREATE TABLE statements.


RE: Create MySQL Tables without using Database Forge Class - ikesela - 10-28-2021

use forge for migration is alot easier and good practise. in case we need to pass our project to next person.


RE: Create MySQL Tables without using Database Forge Class - josh2112o - 10-28-2021

(10-28-2021, 01:02 AM)ikesela Wrote: use forge for migration is alot easier and good practise. in case we need to pass our project to next person.
Thank you for the information. That is great advice and something I haven't considered is the next person who may work on the project too.


RE: Create MySQL Tables without using Database Forge Class - includebeer - 10-28-2021

Or just run a .sql file in your database instead of doing it in php.


RE: Create MySQL Tables without using Database Forge Class - josh2112o - 10-28-2021

(10-28-2021, 03:17 PM)includebeer Wrote: Or just run a .sql file in your database instead of doing it in php.
Yes, that is always an option. Thank you for the suggestion.


RE: Create MySQL Tables without using Database Forge Class - hytadapter - 12-23-2021

[quote pid="391088" dateline="1635459429"]
Thanks for the suggestion brother, it works just fine.
[/quote]