Exemple #1
0
 public function index()
 {
     $bDrop = $this->uri->segment(3);
     $aTableNames = modelsToTableNames();
     foreach ($aTableNames as $k => $sTableName) {
         $oSqlBuilder = new SqlBuilder();
         //** Build tables
         $oTableName = new $k();
         $sCreateSql = $oSqlBuilder->setTableName($sTableName)->getCreateTableString($oTableName->db);
         $this->db->query('FLUSH TABLES;');
         if ($bDrop) {
             $this->db->query($oSqlBuilder->getDropTableString());
         }
         if (!tableExists($sTableName)) {
             $this->db->query($sCreateSql);
         }
         //** Add in any default data
         foreach ($oSqlBuilder->getDefaultDataArray($oTableName->data) as $v) {
             //$oTableName->
             $this->db->query($v);
         }
     }
     foreach ($aTableNames as $k => $sTableName) {
         $oTableName = new $k();
         //** Make forms
         if (!empty($oTableName->form)) {
             $oFormBuilder = new FormBuilder();
             $sForm = $oFormBuilder->setTableName($sTableName)->setFormName($sTableName)->setFormData($oTableName->form)->getFormString();
             createFile('views/admin/includes/forms/' . $sTableName . '_form.php', $sForm);
         }
     }
 }