示例#1
0
 public function createTables()
 {
     $con = $this->em->getConnection();
     $mysql_types = array('varchar', 'tinyint', 'text', 'date', 'smallint', 'mediumint', 'int', 'bigint', 'float', 'double', 'decimal', 'datetime', 'timestamp', 'time', 'year', 'char', 'tinyblob', 'tinytext', 'blob', 'mediumblob', 'mediumtext', 'longblob', 'longtext', 'enum', 'set', 'bit', 'bool', 'binary', 'varbinary');
     if (!empty($this->info->tables) && is_array($this->info->tables)) {
         foreach ($this->info->tables as $table_name => $table_fields) {
             $sql = "CREATE TABLE IF NOT EXISTS `{$this->conf->db_prefix}" . \Control\Core::quote_smart($table_name) . "` (";
             $fields = array();
             foreach ($table_fields as $field_name => $field_info) {
                 // Название поля и тип
                 $field_type = in_array($field_info['type'], $mysql_types) ? $field_info['type'] : 'text';
                 $field = "`" . \Control\Core::quote_smart($field_name) . "` {$field_type}";
                 // Длина/значения
                 if (isset($field_info['length'])) {
                     $field_length = intval($field_info['length']);
                     $field .= "(" . $field_length . ")";
                 }
                 // not_null
                 if (isset($field_info['not_null']) && $field_info['not_null'] == 1) {
                     $field .= " not null";
                 }
                 // default
                 if (isset($field_info['default']) && $field_info['default'] != '') {
                     $field .= " default '" . \Control\Core::quote_smart($field_info['default']) . "'";
                 }
                 // auto_increment
                 if (isset($field_info['auto_increment']) && $field_info['auto_increment'] == 1) {
                     $field .= " auto_increment";
                 }
                 $fields[] = $field;
             }
             $sql .= implode(',', $fields);
             $sql .= ", PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
             try {
                 $con->executeQuery($sql);
             } catch (Exception $e) {
                 echo $this->name . '. Ошибка:<br/>' . $e . '<br/>' . $sql . '<br/><br/>';
             }
         }
     }
 }
示例#2
0
 public function pageInfoAction()
 {
     $module_name = !empty($_POST['module']) ? \Control\Core::quote_smart($_POST['module']) : '';
     $page_name = !empty($_POST['page']) ? \Control\Core::quote_smart($_POST['page']) : '';
     $info = $this->repMenu->findOneBy(array('module' => $module_name, 'page' => $page_name));
     if (!$info) {
         return false;
     }
     $info = array('main_page' => $info->page, 'options' => $info->options);
     $output = json_encode($info);
     return $output;
 }