/** * Коннектор * * @return void */ public function newConnect($config = []) { if (!$this->checkConfig($config)) { return false; } extract($config); parent::__construct($host, $user, $pass, $base); $this->debugger = !empty($debug) ? new SqlDebug($config) : null; $this->prefix = @$prefix; if ($this->connect_error) { AbcError::logic(' Component Mysqli: ' . $this->connect_error); return false; } $this->set_charset("utf8"); }
/** * Установка маршрутов * * @return void */ protected function setRoute($default = false) { if ($default) { $this->route = $this->defaultRoute; } else { foreach ($this->routes as $num => $rout) { if (!empty($this->defaultKeys[$num])) { $this->route[$this->defaultKeys[$num]] = $rout; } else { AbcError::logic(ABC_ERROR_ROUTES_RULE); } } } }
/** * Генерирует меню навигации * * @param string $param * * @return string */ public function createMenu($param = 'num') { if (is_null($this->total)) { AbcError::logic(ABC_NO_TOTAL); } $this->param = $param; $count = ceil($this->total / $this->numRows / $this->numColumns); $menu = "\n<!-- Paginator begin -->\n"; if ($count < 13) { $i = 1; $cnt = $count; } else { if ($this->numPage > 10) { $menu .= $this->createLink($this->numPage - 10, '-10<', 'top'); } if ($count > 12) { if ($this->numPage == 7) { $menu .= $this->createLink(1, 1); } elseif ($this->numPage == 8) { $menu .= $this->createLink(1, 1) . $this->createLink(2, 2); } elseif ($this->numPage > 7) { $menu .= $this->createLink(1, 1) . $this->createLink(2, 2) . $this->createLink(0, '...', 'top', false); } } if ($this->numPage < 6) { $i = 1; $cnt = 10; } elseif ($this->numPage >= $count) { $i = $count - 10; $cnt = $count; } else { $i = $this->numPage - 5; $cnt = $count; } if ($this->numPage < 6) { $cnt = $i + 9; } elseif ($count - $i > 10) { $cnt = $i + 10; } } while ($i <= $cnt) { if ($i == $this->numPage) { $menu .= $this->createLink($i, $i, 'active', false); } else { $menu .= $this->createLink($i, $i); } $i++; } if ($count > 12) { if ($this->numPage < $count - 6) { $menu .= $this->createLink(0, '...', 'top', false) . $this->createLink($count - 1, $count - 1); } if ($this->numPage < $count - 5) { $menu .= $this->createLink($count, $count); } } $end = $this->numPage + 10 > $count ? $count : $this->numPage + 10; if ($this->numPage < $count - 5 && $count - $this->numPage >= 10) { $menu .= $this->createLink($end, '>+10', 'top'); } return $menu . "\n<!-- Paginator end -->\n"; }
/** * Метод проверки повтора оператора * * @param array $operand */ public function checkDuble($operand) { if (isset($this->operands[$operand])) { AbcError::logic(' Component DbCommand: ' . ABC_SQL_ERROR); } }