function gwt_igniter($option) { if (!isset($option)) { echo "Please add your option jso or ci_model"; return; } // Configuration $host = 'localhost:3306'; $user = '******'; $pass = '******'; $database = 'demo'; // Connect to the MySQL database $conn = mysql_connect($host, $user, $pass) or die("Could not connect to database\n"); mysql_select_db($database, $conn) or die("Could not connect to {$database}\n"); // Query to get list of tables $result = mysql_query("SHOW TABLES FROM {$database}", $conn); if ($result) { $output = array(); while ($row = mysql_fetch_array($result)) { $tableName = $row[0]; if ($tableName == "metadata" || $tableName == "xe") { echo $tableName . " <b>Skipped</b><br>"; continue; } else { if (!$this->isInMetadata($tableName) && $option == "create") { $this->metadata->tablename = $tableName; $this->metadata->use_scaffolding = 0; $this->metadata->save(); } else { if (!$this->use_scaffolding($tableName)) { echo $tableName . " <b>Skipped</b><br>"; continue; } } } $table_object = new Table($tableName); //create table object if ($this->lang->line($tableName)) { $table_object->table_fullname = $this->lang->line($tableName); } else { $table_object->table_fullname = $tableName; } echo "<h1>" . $table_object->table_fullname . "</h1>"; // Get meta data $cols = mysql_query("SHOW COLUMNS FROM {$tableName}", $conn); if ($cols) { while ($col = mysql_fetch_assoc($cols)) { // Add this table to our associative array if (!array_key_exists($tableName, $output)) { $output[$tableName] = array(); } // Add the column definition to our associative array $output[$tableName][$col['Field']] = $col['Type']; // add field for table object $field_object = new TableField(); $field_object->name = $col['Field']; $lan_key = $tableName . "." . $col['Field']; if ($this->lang->line($lan_key)) { $field_object->fullname = $this->lang->line($lan_key); } else { $field_object->fullname = $col['Field']; } $field_object->type = DBUtils::MySQLTypeMapping2Java($col['Type']); $field_object->isNumber = DBUtils::isNumber($col['Type']); $field_object->isDate = DBUtils::isDate($col['Type']); $field_object->isString = DBUtils::isString($col['Type']); if ($col["Key"] == "PRI") { $field_object->setIsKey(true); } else { if ($col['Key'] == "MUL") { $field_object->setIsForeignKey(true); } else { if ($col['Key'] == "UNI") { $field_object->setIsUnique(true); } } } if ($col['Extra'] == "auto_increment") { $field_object->isAutoIncrement = true; } if ($col['Null'] == "NO") { $field_object->isRequire = true; } if ($col['Default']) { $field_object->default = $col['Default']; } //add max length $l = DBUtils::StringLength($col['Type']); if ($l > 0) { $field_object->maxLength = $l; } $table_object->addField1($field_object); } mysql_free_result($cols); // $this->createJSO($table_object); $this->createCIModel($table_object); $this->createCIController($table_object); $this->createCIView($table_object); // $this->createCI_Language($table_object); // $this->createMenu($table_object); echo "<hr/>"; } } // Output results foreach ($output as $table => $cols) { echo "===== {$table} =====<br/>"; foreach ($cols as $field => $type) { echo "{$field} : {$type}<br/>"; } } } // Free result if ($result) { mysql_free_result($result); } // Close connection if ($conn) { mysql_close($conn); } }