#

Tutorial

MCG - Massive Crud Generator


#

Activity feeds at Tik-tok (Reserved)

https://www.tiktok.com/@yudhi_ir
#

Activity feeds at Snack Video (Reserved)

Register Snack Video with android
search: massivecrudgenerator

Please follow/subscribe us for information about new tutorials or demo

Before running MCG, you must first install webserver and create a database


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. :)



Let's try an example from Github first:

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 >


Installation and Runing Program MCG


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

#

#

#

Setting and Licensed

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:

#

Note:
Envato licensed type is reserved.
Never share your register number to other people.

Make Massive CRUD data

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.



Control Menu:

You are required to fill in the name of the file which will be the name of the output



Grid Menu:

You are required to fill in the table name, the table name is used to store fields created in the Field-Menu.



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.



Example of data entry:

  • Data-1
    • Control Menu:
      • File Name: sex
      • Title: Tabel Sex
      • Menu Icon: fa-circle
      • Menu Folder: TABLE
      • Description: Tabel Sex

    • Grid Menu:
      • Tablename: sex
      • Title: sex

    • Field Menu:
      • Fieldname: sex_id
      • Fieldtype: AUTOINC-PRIMARYKEY
      • Attribute: HIDDEN
      • Title: Sex ID

      • Fieldname: sex_desc
      • Fieldtype: VARCHAR
      • Attribute: NORMAL
      • Title: Sex Description
      • Validation - Data Is Unique: {"y","Data double."}
      • Validation - Data Required: {"y","Data required."}
      • Show at Lookup: YES


  • Data-2
    • Control Menu:
      • File Name: edu
      • Title: Table Education Level
      • Menu Icon: fa-circle
      • Menu Folder: TABLE
      • Description: Table Education Level

    • Grid Menu:
      • Tablename: edu
      • Title: edu

    • Field Menu:
      • Fieldname: edu_id
      • Fieldtype: AUTOINC-PRIMARYKEY
      • Attribute: HIDDEN
      • Title: Edu ID

      • Fieldname: edu_code
      • Fieldtype: VARCHAR
      • Attribute: NORMAL
      • Title: Edu Code
      • Validation - Data Is Unique: {"y","Data double."}
      • Validation - Data Required: {"y","Data required."}

      • Fieldname: edu_desc
      • Fieldtype: VARCHAR
      • Attribute: NORMAL
      • Title: Edu Description
      • Validation - Data Required: {"y","Data required."}
      • Show at Lookup: YES


  • Data-3
    • Control Menu:
      • File Name: emp
      • Title: Employee
      • Menu Icon: fa-circle
      • Menu Folder: MASTER
      • Description: Employee

    • Grid Menu:
      • Tablename: emp
      • Title: emp

    • Field Menu:
      • Fieldname: emp_id
      • Fieldtype: AUTOINC-PRIMARYKEY
      • Attribute: HIDDEN
      • Title: Emp ID

      • Fieldname: emp_name
      • Fieldtype: VARCHAR
      • Attribute: NORMAL
      • Title: Emp Name
      • Show at Lookup: YES

      • Fieldname: emp_bday
      • Fieldtype: DATE
      • Attribute: NORMAL
      • Title: Birth Day

      • Fieldname: sex_id
      • Fieldtype: LOOKUP-COMBO
      • Attribute: HIDDEN

      • Fieldname: sex_desc
      • Fieldtype: RELATION
      • Attribute: NORMAL

      • Fieldname: edu_code
      • Fieldtype: LOOKUP-COMBO
      • Attribute: HIDDEN

      • Fieldname: edu_desc
      • Fieldtype: RELATION
      • Attribute: NORMAL


#

Generate Code

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.

#

#



Output result to www directory for mcg_005:

#

How to use SQL script result from MCG 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

#

How to test SQL script result from MCG output

There are 2 ways for testing SQL script from MCG output



1. Common command:

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




2. Calling script result from MCG output:

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;



if you use PhpMyAdmin

#

Note: you must create MySql database and called name: mcg_db

File/Directory Structure Web Server

Structure mcg_005:
#

Structure mcg_012:

---reserved

Samples PHP Code with PDO Connection

This samples use a PDO connection, to enable PDO connection in php.ini file,
you have to uncomment the line becomes:

  • extension=pdo_mysql
  • extension=pdo_pgsql
Then restart your web server.


For the mcg_005 program, Samples at directory mcg_testing
Copy that samples to your webserver at target directory:
httdocs or maybe www

you can call in your browser with:

http://localhost/mcg_testing/mcg_005/sex.php
http://localhost/mcg_testing/mcg_005/edu.php
http://localhost/mcg_testing/mcg_005/emp.php

Note: you must create MySql database and called name: mcg_db
or you can change databasename then set file inc/conn.php

Samples Standard PHP code

		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();
		}				

Samples PHP code with Codeigniter 4

  • Controllers
  • 
    	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');
    	}	
    	
    
  • Models
  • 
        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();
    	}	
    
#

Quick: speed up script file creation

#

Fast: generate a CRUD file PHP and SQL script

#

Easy: output script file can be used directly