MCG - Massive Crud Generator
Install your favourite webserver.
I use laragon and MySQL database for testing.
edit php.ini and set
extension=pdo_mysql
extension=pdo_pgsql
Open your favourite database-tool, create MySQL database
-- database: mcg_db
-- Character set: utf8 (UTF-8 Unicode)
-- Collation: utf8_general_ci
I hope you have understood about the webserver function and how to create a database.
Please learn more about laragon webserver with searching by google. :)
Go to menu:
DOWNLOAD >
Then download the following files:
-Testing for CI4
-Template for CI4 LTE3
you will have 2 files:
mcg-ci4-testing-master.zip
mcg-ci4-lte3-templates-master.zip
extract file mcg-ci4-testing-master.zip
to d:\ to do d:\mcg-ci4-testing-master
extract file mcg-ci4-lte3-templates-master.zip
and copy/move
to d:\mcg-ci4-testing-master (overwrite all)
create table from file: ~merge_table_all.sql
create view or procedure from file: ~merge_sql_all.sql
run command:
D:\laragon\bin\php\php-7.4.19-Win32-vc15-x64\php spark serve --port 8080
note: PHP file and directory names please adjust
run in your browser:
http://localhost:8080 >
1. extract zip file. ex: mcg_012-last_update-2022-07-13.zip
2. copy directory installer
3. go to directory installer and run SETUP.exe
4. go to directory d:\MCG
5. run exe file
System will ask you select option 'Include sample data'
Select no. 1 option if you no need sample files
Note:
Running this tool file will make .ini and generator.db files.
If you've ever installed MCG, first backup .ini and generator.db files or rename them
go to 'Setting and Licensed' menu and set what you want.
Directory Output : blank option will save output script same with main program.
Sample setting output for mcg_005:
Sample setting output for mcg_012:
Register licensed type:
go to 'Source Data' menu.
There are 3 sections and you must fill every section.
that sections are Control-Menu, Grid-Menu, and Field-Menu.
You are required to fill in the name of the file which will be the name of the output
You are required to fill in the table name, the table name is used to store fields created in the Field-Menu.
Fieldname must be filled with data, then select the appropriate fieldtype.
Each table must have ONE field of type AUTOINC-PRIMARYKEY.
A field of type AUTOINC-PRIMARYKEY is a field of type INTEGER.
For the Attribute field, fill it with HIDDEN if Fieldtype is AUTOINC-PRIMARYKEY.
Data will be craeated if no mistake in Source Data. You can see at Log Monitor.
Fix your error, and repeat again this proccess.
File result will be created at Directory Output.
Open your favourite database-tool, create database and called name: mcg_db
run or copy paste script from result MGC tool: ~merge_table_all.sql
if you use PhpMyAdmin
run or copy paste ~merge_sql_all.sql
if you use PhpMyAdmin
There are 2 ways for testing SQL script from MCG output
INSERT INTO sex (sex_id, sex_desc) VALUES (1, 'Laki-laki'), (2, 'Perempuan'); INSERT INTO edu (edu_id, edu_code, edu_desc) VALUES (1, 'TK', 'Taman Kanak-kanak'), (2, 'SD', 'Sekolah Dasar'), (3, 'SMP', 'Sekolah Menengah Pertama'), (4, 'SMU', 'Sekolah Menengah Umum'), (5, 'UNIV', 'Universitas'); UPDATE sex SET sex_desc='Male' WHERE sex_id=1 DELETE FROM sex WHERE sex_id=1 SELECT sex.sex_id, sex.sex_desc FROM sex
CALL sex_one_add(1, 'Laki-laki'); CALL sex_one_add(2, 'Perempuan'); CALL sex_one_edit(1, 'Male'); CALL sex_one_delete(1); SELECT * from sex_one_view;
This samples use a PDO connection,
to enable PDO connection in php.ini file,
you have to uncomment the line becomes:
foreach ($rows as $row){ if($row["sex_id"] == null || $row["sex_id"] == "") $row["sex_id"] = "0"; if($row["sex_desc"] == null) $row["sex_desc"] = ""; $sql = "CALL sex_one_edit"; $sql .= " ("; $sql .= ":sex_id"; $sql .= ",:sex_desc"; $sql .= ")"; $rs = $myconn->prepare($sql); $rs->bindParam(':sex_id', $row['sex_id']); $rs->bindParam(':sex_desc', $row['sex_desc']); $rs->execute(); }
public function saveedit_one($id) { $arrResult=$this->Sex_model->saveedit_one([ 'sex_id' => $id , 'sex_desc' => $this->request->getVar('sex_desc') ]); session()->setFlashdata('pesan', 'Data berhasil diubah.'); return redirect()->to('/sex'); }
public function saveedit_one($arrdata) { $sql_edit = " CALL Sex_one_edit"; $sql_edit.= " ("; $sql_edit.= "'".$arrdata['sex_id']."'"; $sql_edit.= ",'".$arrdata['sex_desc']."'"; $sql_edit.= ")"; return $this->db->query($sql_edit)->getRowArray(); }