├── bootstrap-3.3.7-dist ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── js │ ├── npm.js │ └── bootstrap.min.js └── css │ ├── jumbotron-narrow.css │ ├── bootstrap-theme.min.css │ ├── bootstrap-theme.min.css.map │ ├── bootstrap-theme.css │ └── bootstrap-theme.css.map ├── core ├── conn_generate.php ├── generate.php ├── create_generate.php ├── function.php ├── edit_generate.php ├── read_generate.php └── generate_function.php ├── README.md └── index.php /bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/php-CRUD-Generator/HEAD/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/php-CRUD-Generator/HEAD/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/php-CRUD-Generator/HEAD/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gandhi-wibowo/php-CRUD-Generator/HEAD/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /bootstrap-3.3.7-dist/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /core/conn_generate.php: -------------------------------------------------------------------------------- 1 | 22 | "; 23 | if(mkdir("../config")){ 24 | createFile($string, "../config/conn.php"); 25 | } 26 | } 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # php-CRUD-Generator 2 | 3 | ## How to use 4 | 5 | ``` 6 | a. letakkan folder php-Crud-Generator pada localhost 7 | b. buka localhost/php-Crud-Generator dari browser 8 | c. pada form "create database connection" isikan dengan benar : hostname #biasanya localhost, 9 | database name #adalah nama database yang akan di generate kan CRUD nya, database user #biasanya root, 10 | database password #biasanya kalau di windows di kosongkan saja, link project #copykan saja url 11 | yang di tampilkan pada browser. next klik tombol generate config file 12 | d. next pilih tabel, dan tekan generate atau bisa langsung menekan generate All 13 | e. daftar folder yang telah di generate akan muncul pada "Daftar folder" 14 | ``` 15 | 16 | 17 | ## Cooming Soon 18 | 19 | 1. Checker for Chmod & Chown (Linux Mode) 20 | 2. Security from SQL-injection 21 | 3. Just bootstrap table or bootstrap datatables 22 | 4. Pagination 23 | 5. simple form login 24 | 6. menu generator 25 | 7. etc 26 | 27 | ## Update 28 | 29 | 1. Adding Generate All 30 | 2. Adding form for Create connection file from web browser (21 Des 16) 31 | 3. Adding Bootstrap Template for Generated file 32 | 4. Adding Notif for Generated file (Create, Edit, Delete) 33 | 34 | 35 | > written with <3 by Me Gandhi Wibowo 36 | -------------------------------------------------------------------------------- /core/generate.php: -------------------------------------------------------------------------------- 1 | 64 | -------------------------------------------------------------------------------- /bootstrap-3.3.7-dist/css/jumbotron-narrow.css: -------------------------------------------------------------------------------- 1 | /* Space out content a bit */ 2 | body { 3 | padding-top: 20px; 4 | padding-bottom: 20px; 5 | } 6 | 7 | /* Everything but the jumbotron gets side spacing for mobile first views */ 8 | .header, 9 | .marketing, 10 | .footer { 11 | padding-right: 15px; 12 | padding-left: 15px; 13 | } 14 | 15 | /* Custom page header */ 16 | .header { 17 | padding-bottom: 20px; 18 | border-bottom: 1px solid #e5e5e5; 19 | } 20 | /* Make the masthead heading the same height as the navigation */ 21 | .header h3 { 22 | margin-top: 0; 23 | margin-bottom: 0; 24 | line-height: 40px; 25 | } 26 | 27 | /* Custom page footer */ 28 | .footer { 29 | padding-top: 19px; 30 | color: #777; 31 | border-top: 1px solid #e5e5e5; 32 | } 33 | 34 | /* Customize container */ 35 | @media (min-width: 768px) { 36 | .container { 37 | max-width: 730px; 38 | } 39 | } 40 | 41 | 42 | /* Main marketing message and sign up button */ 43 | .jumbotron { 44 | text-align: center; 45 | border-bottom: 1px solid #e5e5e5; 46 | } 47 | .jumbotron .btn { 48 | padding: 14px 24px; 49 | font-size: 21px; 50 | } 51 | 52 | /* Supporting marketing content */ 53 | .marketing { 54 | margin: 40px 0; 55 | } 56 | .marketing p + h4 { 57 | margin-top: 28px; 58 | } 59 | 60 | /* Responsive: Portrait tablets and up */ 61 | @media screen and (min-width: 768px) { 62 | /* Remove the padding we set earlier */ 63 | .header, 64 | .marketing, 65 | .footer { 66 | padding-right: 0; 67 | padding-left: 0; 68 | } 69 | /* Space out the masthead */ 70 | .header { 71 | margin-bottom: 30px; 72 | } 73 | /* Remove the bottom border on the jumbotron for visual effect */ 74 | .jumbotron { 75 | border-bottom: 0; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /core/create_generate.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Read $table 14 | /bootstrap-3.3.7-dist/css/bootstrap.min.css\" > 15 | /bootstrap-3.3.7-dist/css/bootstrap-theme.min.css\"> 16 | /bootstrap-3.3.7-dist/css/jumbotron-narrow.css\"> 17 | 18 | 19 | 20 | 21 | 22 |
23 |
24 |
25 |
26 |
Form Input $table
27 |
28 |
29 | "; 30 | $nopf = NoPrimaryField($table); 31 | foreach($nopf as $field){ 32 | $string .=" 33 |
34 | 35 | 36 |
"; 37 | } 38 | $string .= " 39 |
40 |
41 |
42 |
43 |
44 |
45 | 46 | 47 | 48 | "; 49 | createFile($string, "../".$table."/create.php"); 50 | } 51 | ?> 52 | -------------------------------------------------------------------------------- /core/function.php: -------------------------------------------------------------------------------- 1 | $table['TABLE_NAME']); 14 | } 15 | return $fields; 16 | } 17 | 18 | function PrimaryField($table) 19 | { 20 | $query = "SELECT COLUMN_NAME,COLUMN_KEY FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA= '".DB_NAME."' AND TABLE_NAME='$table' AND COLUMN_KEY = 'PRI'"; 21 | $exe = mysqli_query(Connect(),$query); 22 | $pf = mysqli_fetch_array($exe); 23 | return $pf['COLUMN_NAME']; 24 | } 25 | 26 | function NoPrimaryField($table){ 27 | $query = "SELECT COLUMN_NAME,COLUMN_KEY,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='".DB_NAME."' AND TABLE_NAME='$table' AND COLUMN_KEY <> 'PRI'"; 28 | $exe = mysqli_query(Connect(),$query); 29 | while($column = mysqli_fetch_array($exe)){ 30 | $column_name[] = array('column_name' => $column['COLUMN_NAME']); 31 | } 32 | return $column_name; 33 | } 34 | 35 | function AllField($table){ 36 | $query = "SELECT COLUMN_NAME,COLUMN_KEY,DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='".DB_NAME."' AND TABLE_NAME='$table'"; 37 | $exe = mysqli_query(Connect(),$query); 38 | while($column = mysqli_fetch_array($exe)){ 39 | $column_name[] = array('column_name' => $column['COLUMN_NAME']); 40 | } 41 | return $column_name; 42 | } 43 | 44 | function createFile($string, $path) 45 | { 46 | $create = fopen($path, "wb") or die("Unable to open file!"); 47 | fwrite($create, $string); 48 | fclose($create); 49 | return $path; 50 | } 51 | 52 | function Replace($table,$nm_file,$car,$car_rep){ 53 | $str=implode("", file("../".$table."/".$nm_file.".php")); 54 | $fo=fopen("../".$table."/".$nm_file.".php",'wb'); 55 | $str=str_replace($car,$car_rep,$str); 56 | fwrite($fo,$str,strlen($str)); 57 | } 58 | 59 | ?> 60 | -------------------------------------------------------------------------------- /core/edit_generate.php: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Edit $table 20 | /bootstrap-3.3.7-dist/css/bootstrap.min.css\" > 21 | /bootstrap-3.3.7-dist/css/bootstrap-theme.min.css\"> 22 | /bootstrap-3.3.7-dist/css/jumbotron-narrow.css\"> 23 | 24 | 25 | 26 | 27 |
28 |
29 |
30 |
31 |
Form Edit $table
32 |
33 |
34 | \"> 35 | 37 | "; 38 | foreach($nopf as $field){ 39 | $string .=" 40 |
41 | 42 | \"> 43 |
44 | "; 45 | } 46 | $string .=" 47 | 48 | "; 49 | $string .= " 50 |
51 | 52 |
53 |
54 | 55 |
56 |
57 |
58 | 59 | 60 | "; 61 | 62 | createFile($string, "../".$table."/edit.php"); 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /core/read_generate.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Read $table 18 | /bootstrap-3.3.7-dist/css/bootstrap.min.css\" > 19 | /bootstrap-3.3.7-dist/css/bootstrap-theme.min.css\"> 20 | /bootstrap-3.3.7-dist/css/jumbotron-narrow.css\"> 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |
29 | 31 |
alert-dismissable\"> 32 | × 33 | Notif ! 34 |
35 |
36 | 37 | 38 | Tambah 39 |
40 |
41 | 42 | 43 | 44 | 45 | "; 46 | foreach ($nopf as $th) { 47 | $string .= " \n"; 48 | } 49 | $string .= " 50 | 51 | 52 | 53 | 54 | \"; 59 | echo \"\"; \n"; 60 | foreach ($nopf as $field) { 61 | $string .="echo \"\"; \n"; 62 | } 63 | $string .= " 64 | echo \"\"; 70 | echo \"\"; 76 | } 77 | ?> 78 | "; 79 | 80 | $string .=" 81 | 82 | 83 |
No".$th['column_name']."Opsi
\".\$no++.\"\".\$data['".$field['column_name']."'].\" 65 |
66 | 67 | 68 |
69 |
71 |
72 | 73 | 74 |
75 |
84 |
85 | 86 |
87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | "; 96 | createFile($string, "../".$table."/index.php"); 97 | } 98 | ?> 99 | -------------------------------------------------------------------------------- /core/generate_function.php: -------------------------------------------------------------------------------- 1 | \$data['".$fieldName['column_name']."'],\n\t\t"; 16 | } 17 | $string .= " 18 | ); 19 | } 20 | return \$datas; 21 | } 22 | "; 23 | $string .=" 24 | function GetOne(\$id){ 25 | \$query = \"SELECT * FROM `$table` WHERE `$pf` = '\$id'\"; 26 | \$exe = mysqli_query(Connect(),\$query); 27 | while(\$data = mysqli_fetch_array(\$exe)){ 28 | \$datas[] = array("; 29 | $fields = AllField($table); 30 | foreach($fields as $fieldName){ 31 | $string .= "'".$fieldName['column_name']."' => \$data['".$fieldName['column_name']."'], \n\t\t"; 32 | } 33 | $string .= " 34 | ); 35 | } 36 | return \$datas; 37 | } 38 | "; 39 | $string .=" 40 | function Insert(){ 41 | "; 42 | $nopf = NoPrimaryField($table); 43 | foreach($nopf as $fieldName){ 44 | $string .="\$".$fieldName['column_name']."=\$_POST['".$fieldName['column_name']."']; \n\t\t"; 45 | } 46 | $string .=" 47 | \$query = \"INSERT INTO `$table` ("; 48 | foreach($fields as $fieldName){ 49 | $string .="`".$fieldName['column_name']."`,"; 50 | } 51 | $string .=") 52 | VALUES (NULL,"; 53 | foreach($nopf as $fieldName){ 54 | $string .="'\$".$fieldName['column_name']."',"; 55 | } 56 | $string .=")\"; 57 | \$exe = mysqli_query(Connect(),\$query); 58 | if(\$exe){ 59 | // kalau berhasil 60 | \$_SESSION['message'] = \" Data Sudah disimpan \"; 61 | \$_SESSION['mType'] = \"success \"; 62 | header(\"Location: index.php\"); 63 | } 64 | else{ 65 | \$_SESSION['message'] = \" Data Gagal disimpan \"; 66 | \$_SESSION['mType'] = \"danger \"; 67 | header(\"Location: index.php\"); 68 | } 69 | }"; 70 | $string .=" 71 | function Update(\$id){ 72 | "; 73 | $nopf = NoPrimaryField($table); 74 | foreach($nopf as $fieldName){ 75 | $string .="\$".$fieldName['column_name']."=\$_POST['".$fieldName['column_name']."']; \n\t\t"; 76 | } 77 | $string .=" 78 | \$query = \"UPDATE `$table` SET "; 79 | foreach($nopf as $fieldName){ 80 | $string .="`".$fieldName['column_name']."` = '\$".$fieldName['column_name']."',"; 81 | } 82 | $string .="WHERE `$pf` = '\$id'"; 83 | $string .="\"; 84 | \$exe = mysqli_query(Connect(),\$query); 85 | if(\$exe){ 86 | // kalau berhasil 87 | \$_SESSION['message'] = \" Data Sudah diubah \"; 88 | \$_SESSION['mType'] = \"success \"; 89 | header(\"Location: index.php\"); 90 | } 91 | else{ 92 | \$_SESSION['message'] = \" Data Gagal diubah \"; 93 | \$_SESSION['mType'] = \"danger \"; 94 | header(\"Location: index.php\"); 95 | } 96 | }"; 97 | $string .=" 98 | function Delete(\$id){ 99 | \$query = \"DELETE FROM `$table` WHERE `$pf` = '\$id'\"; 100 | \$exe = mysqli_query(Connect(),\$query); 101 | if(\$exe){ 102 | // kalau berhasil 103 | \$_SESSION['message'] = \" Data Sudah dihapus \"; 104 | \$_SESSION['mType'] = \"success \"; 105 | header(\"Location: index.php\"); 106 | } 107 | else{ 108 | \$_SESSION['message'] = \" Data Gagal dihapus \"; 109 | \$_SESSION['mType'] = \"danger \"; 110 | header(\"Location: index.php\"); 111 | } 112 | } 113 | 114 | "; 115 | $string .=" 116 | if(isset(\$_POST['insert'])){ 117 | Insert(); 118 | } 119 | else if(isset(\$_POST['update'])){ 120 | Update(\$_POST['$pf']); 121 | } 122 | else if(isset(\$_POST['delete'])){ 123 | Delete(\$_POST['$pf']); 124 | } 125 | ?> 126 | "; 127 | 128 | mkdir("../".$table); 129 | createFile($string, "../".$table."/func.php"); 130 | Replace($table,"func",",)",")"); 131 | Replace($table,"func",",WHERE"," WHERE"); 132 | } 133 | ?> 134 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | PHP CRUD Generator 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |
49 |
50 | 54 |

PHP CRUD Generator

55 |
56 |
57 |
58 | 61 |
62 |
63 |
64 | Remove Config 65 |
66 |
67 |

68 | Config untuk koneksi ke database telah dibuat.
69 | Namun terjadi kesalahan yang mengakibatkan tidak terhubungnya database ke system ini.
70 | Silahkan ubah data pada config/conn.php untuk memperbaikinya
71 | Atau hapus dan buat ulang menggunakan button ini ==> Hapus 72 |

73 | 74 |
75 |
76 |
77 | 78 | 79 |
80 |
81 |
82 |
83 | One By One 84 |
85 |
86 |
87 | 96 |
97 | 98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | Generate All 106 |
107 |
108 |
109 | 110 |
111 |
112 |
113 |
114 |
115 | 117 |
118 |
119 |
120 | Create Database Connection 121 |
122 |
123 |
124 |
125 | 126 |
127 | 128 |
129 |
130 |
131 | 132 |
133 | 134 |
135 |
136 |
137 | 138 |
139 | 140 |
141 |
142 |
143 | 144 |
145 | 146 |
147 |
148 |
149 | 150 |
151 | 152 |
153 |
154 |
155 |
156 |
157 | 158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 | 166 | 167 | 168 |
169 |
170 |
171 | Daftar Folder 172 |
173 |
174 | 175 |
176 | 177 | 178 | 179 | 180 | 181 | 193 | 196 | 199 | 200 | 204 | 205 |
194 | 195 | 197 | Delete 198 |
206 |
207 |
208 |
209 |
210 |
211 |