/**
  * Возвращает список родительских объектов
  * @param string $table Имя таблицы, для которой ищем родителей
  * @return type
  */
 function getParents($table)
 {
     //		$relations = $this->db->exec('SHOW FULL columns from `' . $table . '` LIKE "fko\_%"');
     $relations = CacheQuery::getInstance()->get('cached.parents.' . $table, 'SHOW FULL columns from `' . $table . '` LIKE "fko\\_%"', null, 'getFull');
     $list = array();
     foreach ($relations as $k => $v) {
         $table = preg_replace('/^fko_/', '', current($v));
         $relTableMeta = Meta::getInstance()->getTableMeta($table);
         /*$relTable = $table;
         			$res = CacheQuery::getInstance()->get(
         				'cached.comment.' . $relTable,
         				'SELECT table_comment FROM information_schema.tables WHERE table_name = "' . $relTable . '"',
         				null,
         				'getFirstRow'
         			);
         //			$res = $this->db->exec('SELECT table_comment 
         //                        FROM
         //                            information_schema.tables
         //                        WHERE 
         //                            table_name = "' . $relTable . '"');*/
         $list[$k]['table'] = $table;
         $list[$k]['name'] = 'fko_' . $table;
         $list[$k]['comment'] = $relTableMeta->get('comment');
         $list[$k]['title'] = $relTableMeta->get('title');
     }
     return $list;
 }
 function deleteField($table, $name)
 {
     if (empty($name) || empty($table)) {
         \helpers\Msg::error('empty_post');
         \helpers\Msg::error('tables.fields.not_deleted');
         return false;
     }
     if (!$this->tablesManager->isValidTableName($table)) {
         \helpers\Msg::warning('tables.wrong_name', $table);
         \helpers\Msg::error('tables.fields.not_deleted');
         return false;
     }
     $fields = $this->getAdditionalFieldsNames($table);
     if (!in_array('af_' . $name, $fields)) {
         \helpers\Msg::warning('tables.fields.not_found');
         \helpers\Msg::error('tables.fields.not_deleted');
         return false;
     }
     $q = "ALTER TABLE `{$table}` DROP `af_{$name}` ";
     if ($this->db->exec($q) !== false) {
         $this->metaWriter->updateFieldList($table);
         \helpers\Msg::success('tables.fields.deleted');
         CacheQuery::getInstance()->reset();
         return true;
     } else {
         if ($this->debugState) {
             \helpers\Msg::warning($this->db->log());
         }
         \helpers\Msg::error('db_error');
     }
     return false;
 }
 function getRowsCount($table)
 {
     if (!$this->isValidTableName($table)) {
         return false;
     }
     $res = CacheQuery::getInstance()->get('cached.table_info.' . $table, 'SELECT COUNT(id) as count_rows FROM `' . $table . '`', null, 'getFirstRow');
     return $res['count_rows'] * 1;
 }