@@ -80,7 +80,7 @@ |
||
| 80 | 80 | foreach ($JsonExtractor->getTablesArray() as $TableName => $TableColumn) { |
| 81 | 81 | |
| 82 | 82 | $this->capsule::schema()->dropIfExists($TableName); |
| 83 | - $this->capsule::schema()->create($TableName, function ($table) use ($TableColumn) { |
|
| 83 | + $this->capsule::schema()->create($TableName, function($table) use ($TableColumn) { |
|
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | foreach ($TableColumn as $column_item) { |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if (is_array($value) && is_object($value[0])) {//check whether it's a array and it's firs element is a object |
| 66 | 66 | |
| 67 | - $table_data = $this->getTable($prefix . $table_name, $value);//get table sql |
|
| 67 | + $table_data = $this->getTable($prefix.$table_name, $value); //get table sql |
|
| 68 | 68 | $this->table[$table_data['tables']['name']] = $table_data['tables']['column']; |
| 69 | 69 | $this->data[$table_data['data']['table']] = $table_data['data']['data']; |
| 70 | 70 | |
| 71 | - $this->toMysqlTables($this->getHighestColumnArray($value), $prefix . $table_name . '_');//get it inside tables |
|
| 71 | + $this->toMysqlTables($this->getHighestColumnArray($value), $prefix.$table_name.'_'); //get it inside tables |
|
| 72 | 72 | |
| 73 | 73 | } elseif (is_array($value) || is_object($value)) {//if it's a array and firs element is not a object |
| 74 | 74 | |
| 75 | - $table_data = $this->getTable($prefix . $table_name, $value); |
|
| 75 | + $table_data = $this->getTable($prefix.$table_name, $value); |
|
| 76 | 76 | $this->table[$table_data['tables']['name']] = $table_data['tables']['column']; |
| 77 | 77 | $this->data[$table_data['data']['table']] = $table_data['data']['data']; |
| 78 | 78 | } |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | } elseif (is_numeric($item)) |
| 241 | 241 | $value[] = $item; |
| 242 | 242 | else |
| 243 | - $value[] = '"' . addcslashes($item, "W") . '"'; |
|
| 243 | + $value[] = '"'.addcslashes($item, "W").'"'; |
|
| 244 | 244 | } |
| 245 | - $String[] = '(' . implode(",", $value) . ')'; |
|
| 245 | + $String[] = '('.implode(",", $value).')'; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - return "values" . implode(", ", $String); |
|
| 248 | + return "values".implode(", ", $String); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | /** |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | { |
| 257 | 257 | $String = []; |
| 258 | 258 | foreach ($array as $column) { |
| 259 | - $String[] = "`" . JsonExtractor::snakeCase($column['name']) . "`"; |
|
| 259 | + $String[] = "`".JsonExtractor::snakeCase($column['name'])."`"; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | return implode(",", $String); |
@@ -275,6 +275,6 @@ discard block |
||
| 275 | 275 | } elseif (empty($Data)) |
| 276 | 276 | return $empty_val; |
| 277 | 277 | else |
| 278 | - return (string)$Data; |
|
| 278 | + return (string) $Data; |
|
| 279 | 279 | } |
| 280 | 280 | } |
@@ -91,8 +91,9 @@ discard block |
||
| 91 | 91 | $column = $this->getColumn($this->getHighestColumnArray($data)); |
| 92 | 92 | |
| 93 | 93 | |
| 94 | - if ($this->snake_case_table) |
|
| 95 | - $table = $this->snakeCase($table); |
|
| 94 | + if ($this->snake_case_table) { |
|
| 95 | + $table = $this->snakeCase($table); |
|
| 96 | + } |
|
| 96 | 97 | |
| 97 | 98 | $table_data = $this->getData($data, $column); |
| 98 | 99 | |
@@ -193,8 +194,9 @@ discard block |
||
| 193 | 194 | */ |
| 194 | 195 | public static function getHighestColumnArray($array) |
| 195 | 196 | { |
| 196 | - if (is_object($array) || (is_array($array) && !is_object($array[0]) && !is_array($array[0]))) |
|
| 197 | - return $array; |
|
| 197 | + if (is_object($array) || (is_array($array) && !is_object($array[0]) && !is_array($array[0]))) { |
|
| 198 | + return $array; |
|
| 199 | + } |
|
| 198 | 200 | |
| 199 | 201 | $Highest = false; |
| 200 | 202 | $ColumnCount = false; |
@@ -237,10 +239,11 @@ discard block |
||
| 237 | 239 | foreach ($item_row as $item) { |
| 238 | 240 | if (empty($item) && !is_numeric($item)) { |
| 239 | 241 | $value[] = "null"; |
| 240 | - } elseif (is_numeric($item)) |
|
| 241 | - $value[] = $item; |
|
| 242 | - else |
|
| 243 | - $value[] = '"' . addcslashes($item, "W") . '"'; |
|
| 242 | + } elseif (is_numeric($item)) { |
|
| 243 | + $value[] = $item; |
|
| 244 | + } else { |
|
| 245 | + $value[] = '"' . addcslashes($item, "W") . '"'; |
|
| 246 | + } |
|
| 244 | 247 | } |
| 245 | 248 | $String[] = '(' . implode(",", $value) . ')'; |
| 246 | 249 | } |
@@ -272,9 +275,10 @@ discard block |
||
| 272 | 275 | $Data = trim($Data); |
| 273 | 276 | if (is_numeric($Data)) { |
| 274 | 277 | return $Data + 0; |
| 275 | - } elseif (empty($Data)) |
|
| 276 | - return $empty_val; |
|
| 277 | - else |
|
| 278 | - return (string)$Data; |
|
| 278 | + } elseif (empty($Data)) { |
|
| 279 | + return $empty_val; |
|
| 280 | + } else { |
|
| 281 | + return (string)$Data; |
|
| 282 | + } |
|
| 279 | 283 | } |
| 280 | 284 | } |
@@ -45,8 +45,8 @@ |
||
| 45 | 45 | */ |
| 46 | 46 | function validate($json) |
| 47 | 47 | { |
| 48 | - if(is_array($json)){ |
|
| 49 | - return (object)[ |
|
| 48 | + if (is_array($json)) { |
|
| 49 | + return (object) [ |
|
| 50 | 50 | $this->main_table_name=>$json |
| 51 | 51 | ]; |
| 52 | 52 | } |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?PHP |
| 2 | 2 | |
| 3 | -function sd(){ |
|
| 3 | +function sd() { |
|
| 4 | 4 | $Args = func_get_args(); |
| 5 | 5 | $console = new \PhpConsoleColor\Console(); |
| 6 | 6 | |
| 7 | - foreach($Args as $str) { |
|
| 7 | + foreach ($Args as $str) { |
|
| 8 | 8 | $str = print_r($str, TRUE); |
| 9 | 9 | $console->writeLn("<green>$str</green>"); |
| 10 | 10 | |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| 20 | -function s(){ |
|
| 20 | +function s() { |
|
| 21 | 21 | $Args = func_get_args(); |
| 22 | 22 | $console = new \PhpConsoleColor\Console(); |
| 23 | 23 | |
| 24 | - foreach($Args as $str) { |
|
| 24 | + foreach ($Args as $str) { |
|
| 25 | 25 | $str = print_r($str, TRUE); |
| 26 | 26 | $console->writeLn("<green>$str</green>"); |
| 27 | 27 | } |