public static function configByName($name) { $config_line = new ConfigLine(false, $name); if ($config_line->fetch()) { return $config_line->getValue(); } else { return false; } }
public function __construct($offset = false, $limit = false, $sort_by = false, $order = false) { $result = array(); if ($offset !== false) { $this->setOffset((int) $offset); } if ($limit !== false) { $this->setLimit((int) $limit); } if ($sort_by !== false) { $this->setSortBy($sort_by); } if ($order !== false) { $this->SetOrder($order); } // initialize $total_count with the total number of objects in the list (over all pages) try { $stmt = DB::getInstance()->prepare("SELECT COUNT(*) as total_count\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM config"); $stmt->execute(); $total_count = $stmt->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } $this->setTotalCount((int) $total_count['total_count']); //if limit -1 then get all configs if ($this->getLimit() == -1) { $this->setLimit($this->getTotalCount()); } try { $stmt = DB::getInstance()->prepare("SELECT config.id as config_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM config\n\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase :sort_by\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen 'config_id' then config.id\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse NULL\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $this->getOrder() . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT :offset, :limit"); $stmt->bindParam(':offset', $this->getOffset(), PDO::PARAM_INT); $stmt->bindParam(':limit', $this->getLimit(), PDO::PARAM_INT); $stmt->bindParam(':sort_by', $this->getSortBy(), PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { echo $e->getMessage(); echo $e->getTraceAsString(); } foreach ($result as $config_line) { $config_line = new ConfigLine((int) $config_line['config_id']); $config_line->fetch(); $this->config_line_list[] = $config_line; } }
private function config() { $this->_request['api_key'] = isset($this->_request['api_key']) ? $this->_request['api_key'] : 'a'; $user = new User(false, false, false, false, false, $this->_request['api_key']); if ($user->fetch()) { if ($user->getPermission() == 120) { if ($this->get_request_method() == "GET" && (isset($this->_request['id']) || isset($this->_request['name']))) { $this->_request['id'] = isset($this->_request['id']) ? $this->_request['id'] : false; $this->_request['name'] = isset($this->_request['name']) ? $this->_request['name'] : false; $config_line = new ConfigLine((int) $this->_request['id'], $this->_request['name']); if ($config_line->fetch()) { $domxmldata = $config_line->getDomXMLElement($this->domxml); $this->response($this->finishxml($domxmldata), 200); } else { $this->error_code = 1; $this->error_message = "Config not found"; $this->response($this->finishxml(), 404); } } die; } else { $this->error_code = 2; $this->error_message = "Your API-Key has not enough permission."; } } else { $this->error_code = 2; $this->error_message = "The api_key is not valid."; } $this->authentication = 0; $this->response($this->finishxml(), 401); }