/** Get all publications * @param string $sort field to sort by * @param string $params['title'] title of book * @param string $params['authorEditor'] author or editor name * @param string $params['pubYear'] year of publishing * @param string $params['place'] place of publication * @param integer $params['page'] page to retrieve * @return array */ public function getPublications($sort, $params) { $refs = $this->getAdapter(); $select = $refs->select()->from($this->_name)->order($sort); if (isset($params['title']) && $params['title'] != "") { $title = strip_tags($params['title']); $select->where('title LIKE ?', '%' . $title . '%'); } if (isset($params['authorEditor']) && $params['authorEditor'] != "") { $author = strip_tags($params['authorEditor']); $select->where('authors LIKE ?', '%' . $author . '%'); } if (isset($params['pubYear']) && $params['pubYear'] != "") { $pubYear = strip_tags($params['pubYear']); $select->where('publication_year = ?', $pubYear); } if (isset($params['place']) && $params['place'] != "") { $place = strip_tags($params['place']); $select->where('publication_place LIKE ?', '%' . $place . '%'); } $paginator = Zend_Paginator::factory($select); $cache = Zend_registry::get('cache'); if (isset($params['page']) && $params['page'] != "") { $paginator->setCurrentPageNumber((int) $params['page']); } $paginator->setItemCountPerPage(20)->setPageRange(10); return $paginator; }
public function checkChatKeyValidity() { $return = null; $showId = $this->getRequest()->getParam('User')->currentShow; $session = $this->getRequest()->getParam('User')->getSessionKey(); $chatKey = $this->getRequest()->getParam('User')->chatroomKey; if ($chatKey) { try { $stmt = Zend_registry::get('dbh')->proc('show_viewer_authenticate'); $stmt->bindParam(':show', $showId, PDO::PARAM_INT); $stmt->bindParam(':session', $session, PDO::PARAM_STR); $stmt->bindParam(':key', $chatKey, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(Zend_Db::FETCH_OBJ); $stmt->closeCursor(); } catch (Zend_Db_Statement_Exception $e) { echo $e->getMessage(); die(__LINE__); } if ($result) { $return = $result->show; } } return $return; }
/** * Get all carrier */ public function getAll() { $db = Zend_registry::get('db'); $select = $db->select()->from("operadoras"); $stmt = $db->query($select); $carrier = $stmt->fetchAll(); return $carrier; }
public function get_sum_operations_group_by_month($id, $filter) { $where = ' WHERE ' . $this->parse_filter(isset($filter['filter']) ? $filter['filter'] : array(), $join); if (is_array($id) && count($id)) { $where .= " AND `fin_category_id` IN (" . Zend_registry::get('target')->db->escape(trim(implode(',', $id), ',')) . ")"; } elseif (!empty($id)) { $id = (int) $id; $where .= " AND `fin_category_id` = '{$id}' "; } return Zend_Registry::get('target')->db->get_results("SELECT date_format(fin_op.`date`, '%m.%Y') as Mon, fin_op.`fin_category_id`, SUM(fin_op.`operation_sum`) as sum, fin_cat.`category_name`\n\t\t\t\tFROM {$this->table} AS fin_op LEFT JOIN {$this->_financial_cat} as fin_cat ON fin_cat.`id` = fin_op.`fin_category_id` {$where} GROUP BY MONTH(fin_op.`date`),`fin_category_id` ORDER BY Mon,fin_op.`fin_category_id`;\n\t\t\t"); }
public function __construct($spec, $params = array(), $options = null) { parent::__construct($spec, $options); $this->_lang = empty($options['lang']) ? 1 : $options['lang']; if ($options['mode'] == 'add') { $this->_mode = 'add'; $config = Zend_registry::get('config'); $this->_lang = $config->defaultEditLanguage; } $this->_params = $params; }
public function subscribe_decline_price($gift_id, $email, $name, $price) { $gift_id = (int) $gift_id; $price = (int) $price; $email = Zend_Registry::get('target')->db->escape($email); $user_name = Zend_registry::get('target')->db->escape($name); if (!$gift_id) { return false; } Zend_Registry::get('target')->db->query("INSERT INTO {$this->table} (gift_id, email,user_name,old_price) VALUES ({$gift_id}, '{$email}','{$name}',{$price}) ON DUPLICATE KEY UPDATE status=0,old_price={$price};"); return true; }
public function __construct($options = null) { parent::__construct($options); $this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate'); $this->addPrefixPath('Pas_Form_Element', 'Pas/Form/Element/', 'element'); $this->addPrefixPath('Pas_Form_Decorator', 'Pas/Form/Decorator/', 'decorator'); $decorator = array('SimpleInput'); $decoratorSelect = array('SelectInput'); $decorators = array(array('ViewHelper'), array('Description', array('tag' => '', 'placement' => 'append')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label', array('separator' => ' ', 'requiredSuffix' => ' *')), array('HtmlTag', array('tag' => 'li'))); $this->setAttrib('accept-charset', 'UTF-8'); $this->setName('comments'); $comment_author_IP = new Zend_Form_Element_Hidden('user_ip'); $comment_author_IP->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->addFilters(array('StripTags', 'StringTrim'))->setRequired(true)->addValidator('Ip')->setValue($_SERVER['REMOTE_ADDR']); $comment_agent = new Zend_Form_Element_Hidden('user_agent'); $comment_agent->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label')->addFilters(array('StripTags', 'StringTrim'))->setValue($_SERVER['HTTP_USER_AGENT'])->setRequired(true); $comment_subject = new Zend_Form_Element_Hidden('comment_subject'); $comment_subject->removeDecorator('HtmlTag')->addFilters(array('StripTags', 'StringTrim'))->removeDecorator('DtDdWrapper')->removeDecorator('Label')->setRequired(true); $comment_findID = new Zend_Form_Element_Hidden('comment_findID'); $comment_findID->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidators(array('Int'))->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->removeDecorator('Label'); $comment_author = new Zend_Form_Element_Text('comment_author'); $comment_author->setLabel('Enter your name: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter a valid name!')->setDecorators($decorators); $comment_author_email = new Zend_Form_Element_Text('comment_author_email'); $comment_author_email->setLabel('Enter your email address: ')->setDecorators($decorators)->setRequired(true)->setAttrib('size', 40)->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->addValidator('EmailAddress')->addErrorMessage('Please enter a valid email address!')->setDescription('* This will not be displayed to the public'); $comment_type = new Zend_Form_Element_Select('comment_type'); $comment_type->setLabel('Error type: ')->setRequired(true)->setDecorators($decorators)->addMultiOptions(array(NULL => NULL, 'Choose error type' => array('Incorrect ID' => 'Incorrect identification', 'More info' => 'I have further information', 'Incorrect image' => 'Incorrect image', 'Incorrect parish' => 'Incorrect parish', 'Grid reference issues' => 'Grid reference wrong', 'Date found wrong' => 'Date of discovery wrong', 'Spelling errors' => 'Spelling errors', 'Duplicated record' => 'Duplicated record', 'Data problems apparent' => 'Data problems', 'Other' => 'Other reason')))->addErrorMessage('You must enter an error report type'); $comment_author_url = new Zend_Form_Element_Text('comment_author_url'); $comment_author_url->setLabel('Enter your web address: ')->setDecorators($decorators)->setRequired(false)->addFilters(array('StripTags', 'StringTrim', 'StringToLower'))->addErrorMessage('Please enter a valid address!')->setDescription('* Not compulsory'); $comment_content = new Pas_Form_Element_RTE('comment_content'); $comment_content->setLabel('Enter your comment: ')->setRequired(true)->addFilter('StringTrim')->setAttrib('Height', 400)->setAttrib('ToolbarSet', 'Basic')->addFilter('StringTrim')->addFilter('WordChars')->addFilter('HtmlBody')->addFilter('EmptyParagraph')->addErrorMessage('Please enter something in the comments box!'); $config = Zend_registry::get('config'); $privateKey = $config->recaptcha->privatekey; $pubKey = $config->recaptcha->pubkey; $captcha = new Zend_Form_Element_Captcha('captcha', array('captcha' => 'ReCaptcha', 'label' => 'Prove you are not a robot you varmint!', 'captchaOptions' => array('captcha' => 'ReCaptcha', 'privKey' => $privateKey, 'pubKey' => $pubKey, 'theme' => 'clean'))); $hash = new Zend_Form_Element_Hash('csrf'); $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(60); $this->addElement($hash); $submit = new Zend_Form_Element_Submit('submit'); $submit->setAttrib('id', 'submitbutton')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper'); $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $this->addElements(array($comment_findID, $comment_author_IP, $comment_agent, $comment_subject, $comment_author, $comment_author_email, $comment_content, $comment_author_url, $comment_type, $captcha, $submit)); $this->addDisplayGroup(array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_type', 'comment_content', 'captcha', 'submit'), 'details'); } else { $this->addElements(array($comment_findID, $comment_subject, $comment_author_IP, $comment_agent, $comment_author, $comment_author_email, $comment_content, $comment_author_url, $comment_type, $submit)); $this->addDisplayGroup(array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_type', 'comment_content', 'submit'), 'details'); } $this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul')))); $this->details->removeDecorator('HtmlTag'); $this->details->removeDecorator('DtDdWrapper'); $this->details->setLegend('Enter your error report: '); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { if ($acl = Zend_registry::get('Acl')) { if ($user = $request->getParam('User', null)) { if (($roles = $user->getRoles()) && count($roles)) { $clientRole = $roles[0]; $clientHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('Client'); $client = $clientHelper->loadByGroup($clientRole->id); $request->setParam('Client', $client); $request->getParam('View')->register_object('client', $client); } } } }
public function __get($v) { $var = '_' . $v; if (0 === strpos($v, 'is') && strtoupper($v[2]) === $v[2]) { $allowed = Zend_registry::get('Acl')->has(trim(substr($v, 2))); return $allowed; } if (isset($this->{$v})) { return $this->{$v}; } else { if (isset($this->_session()->{$v})) { return strval($this->_session()->{$v}); } elseif (isset($this->_details->{$v})) { return $this->_details->{$v}; } } return null; }
protected function _load($showId = null, $method = null, $preview = 0, $offset = 0, $limit = null, array $portals = array(), array $channels = array(), $series = null, $start = null, $finish = null, $exclude = null, $searchTerm = null, $searchFilter = null, $transcript = null) { $user = $this->getRequest()->getParam('User'); $args = array('type' => $method ? $method : $this->getRequest()->getParam('action', null), 'userId' => $user->id, 'ip' => Showcase_Session::getRemoteIp($this->getRequest()), 'cache' => $user->isCmsUser ? false : true, 'preview' => $user->isCmsUser ? $preview : 0, 'portals' => $user->isCmsUser ? count($portals) ? implode(', ', $portals) : null : $this->getRequest()->getParam('Portal')->id, 'channels' => count($channels) ? implode(', ', $channels) : ($this->getRequest()->getParam('Channel', null) ? $this->getRequest()->getParam('Channel')->id : null), 'series' => $series, 'offset' => $offset, 'limit' => $limit, 'start' => $start ? new Zend_Date($start, Zend_registry::get('locale')) : null, 'finish' => $finish ? new Zend_Date($finish, Zend_registry::get('locale')) : null, 'show' => $showId, 'exclude' => $exclude, 'search' => $searchTerm, 'filter' => $searchFilter, 'transcript' => $transcript); $return = null; if ($args['cache']) { $id = $this->_makeId($method, $args); if ($this->_cache()->test($id)) { $return = unserialize($this->_cache()->load($id)); } } if (!$return) { $return = call_user_func_array(array($this, '_factory'), $args); if ($args['cache']) { $this->_cache()->save(serialize($return), $id); } } return $return; }
/** * Constructor * * Registers form view helper as decorator * * @param mixed $options * @return void */ public function __construct($select, $numberOfColumns, $itemViewscript = null, $options = null) { $this->_db = Zend_registry::get('db'); $_frontController = Zend_Controller_Front::getInstance(); $this->_request = $_frontController->getRequest(); if (null === $this->_view) { require_once 'Zend/Controller/Action/HelperBroker.php'; $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $this->_view = $viewRenderer->view; } if (!empty($options['paginationViewScript'])) { $this->_view->assign('paginationViewScript', $options['paginationViewScript']); } else { $this->_view->assign('paginationViewScript', null); } $this->_view->assign('numberOfColumns', $numberOfColumns); $this->_view->assign('itemViewScript', $itemViewscript); $adapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($adapter); $_config = Zend_Registry::get('config'); $itemPerPage = 12; if (!empty($_config->products->itemPerPage)) { $itemPerPage = $_config->products->itemPerPage; } if (!empty($options['list_options']['perPage'])) { $itemPerPage = $options['list_options']['perPage']; } if ($this->_request->getParam('perPage')) { $itemPerPage = $this->_request->getParam('perPage') == 'all' ? $paginator->getTotalItemCount() : $this->_request->getParam('perPage'); } $pageRange = 5; if (!empty($_config->products->pageRange)) { $pageRange = $_config->products->pageRange; } $paginator->setItemCountPerPage($itemPerPage); $paginator->setCurrentPageNumber($this->_request->getParam('page')); $paginator->setPageRange($pageRange); $this->_view->assign('paginator', $paginator); }
public function subscribeAction() { if (isset($_POST['gift_id']) && isset($_POST['email'])) { $_POST['gift_id'] = (int) $_POST['gift_id']; $_POST['email'] = Zend_registry::get('target')->db->escape($_POST['email']); $_POST['user_name'] = !empty($_POST['user_name']) ? Zend_registry::get('target')->db->escape($_POST['user_name']) : ''; $gift = new gift($_POST['gift_id']); if ($gift->get('id') && !empty($_POST["email"])) { $waiting_gifts = new p_waiting_gifts(); //Отправляем письмо юзеру $et = new email_template('subscribe_user'); $et->assign('USER_NAME', !empty($_POST["user_name"]) ? ", {$_POST["user_name"]}" : '')->assign('GIFT_NAME', $gift->get('display_name'))->assign('URL_GIFT', "http://{$_SERVER['SERVER_NAME']}/" . $gift->get('local_url') . '/?utm_source=email&utm_medium=user&utm_campaign=subscribe_user')->send($_POST["email"], $_POST["user_name"])->send('*****@*****.**'); $waiting_gifts->subscribe($gift->get('id'), $_POST['email'], $_POST['user_name']); } } die; }
/** * Constructor * * Registers form view helper as decorator * * @param mixed $options * @return void */ public function __construct($select, $tables, $field_list, $options = null) { $this->_db = Zend_registry::get('db'); $_frontController = Zend_Controller_Front::getInstance(); $this->_request = $_frontController->getRequest(); if (null === $this->_view) { require_once 'Zend/Controller/Action/HelperBroker.php'; $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); $this->_view = $viewRenderer->view; } if (!empty($options['actionKey'])) { $this->_view->actionKey = $options['actionKey']; } if (!empty($options['commands'])) { $this->_view->assign('commands', $options['commands']); } if (!empty($options['to-excel-action'])) { $this->_view->assign('to_excel_action', $options['to-excel-action']); } else { $this->_view->assign('to_excel_action', 'to-excel'); } if (!empty($options['disable-export-to-excel'])) { $this->_view->assign('disable_export_to_excel', $options['disable-export-to-excel']); } else { $this->_view->assign('disable_export_to_excel', 'false'); } if (!empty($options['enable-print'])) { $this->_view->assign('enable_print', $options['enable-print']); $this->_view->headScript()->appendFile($this->_view->locateFile('jquery.printElement.min.js')); } else { $this->_view->assign('enable_print', 'false'); } if (!empty($options['filters'])) { $this->_view->assign('filters', $options['filters']); foreach ($options['filters'] as $key => $filter) { $filter_val = $this->_request->getParam($key); if (!empty($filter_val)) { if ($filter['associatedTo'] != '') { if (!empty($filter['kindOfFilter']) && $filter['kindOfFilter'] == 'list') { $select->where("{$filter['associatedTo']} = '{$filter_val}'\r\n OR {$filter['associatedTo']} like '%{$filter_val}%'\r\n OR {$filter['associatedTo']} like '%,{$filter_val}'\r\n OR {$filter['associatedTo']} like '{$filter_val},%'\r\n OR {$filter['associatedTo']} like '%,{$filter_val},%'\r\n "); } else { $select->where("{$filter['associatedTo']} = ?", $filter_val); } } } } } else { $this->_view->assign('filters', array()); } if (!empty($options['action_panel'])) { if (!empty($options['action_panel'])) { $field_list['action_panel'] = $options['action_panel']; } if (!empty($options['action_panel']['actions'])) { $this->_view->assign('action_links', $options['action_panel']['actions']); } } $this->_view->assign('field_list', $field_list); if ($this->_request->getParam('order')) { if (in_array($this->_request->getParam('order'), array_keys($field_list))) { $direction = 'ASC'; if (in_array($this->_request->getParam('order-direction'), array('ASC', 'DESC'))) { $direction = $this->_request->getParam('order-direction'); } $select->order("{$this->_request->getParam('order')} {$direction}"); $this->_view->assign('order', $this->_request->getParam('order')); $this->_view->assign('order_direction', $this->_request->getParam('order-direction')); } } $searchfor = $this->_request->getParam('searchfor'); if ($searchfor) { $searching_on = array(); $search_keywords = explode(' ', $searchfor); foreach ($tables as $table => $columns) { foreach ($columns as $column) { $doSearch = true; if (isset($options['onlyColumns'])) { if (!in_array($column, $options['onlyColumns'])) { $doSearch = false; } } else { if (isset($options['excludedColums'])) { if (in_array($column, $options['excludedColums'])) { $doSearch = false; } } } if ($doSearch == true) { array_push($searching_on, $this->_db->quoteInto("{$table}.{$column} LIKE ?", "%{$searchfor}%")); foreach ($search_keywords as $keyword) { array_push($searching_on, $this->_db->quoteInto("{$table}.{$column} LIKE ?", "%{$keyword}%")); } } } } if (!empty($searching_on)) { $select->where(implode(' OR ', $searching_on)); } } $this->_view->assign('searchfor', $searchfor); $adapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($adapter); $_config = Zend_Registry::get('config'); $itemPerPage = 10; if (!empty($_config->lists->itemPerPage)) { $itemPerPage = $_config->lists->itemPerPage; } if (!empty($options['list_options']['perPage'])) { $itemPerPage = $options['list_options']['perPage']; } if ($this->_request->getParam('perPage')) { $itemPerPage = $this->_request->getParam('perPage') == 'all' ? $paginator->getTotalItemCount() : $this->_request->getParam('perPage'); } $pageRange = 5; if (!empty($_config->lists->pageRange)) { $pageRange = $_config->lists->pageRange; } $paginator->setItemCountPerPage($itemPerPage); $paginator->setCurrentPageNumber($this->_request->getParam('page')); $paginator->setPageRange($pageRange); $this->_view->assign('paginator', $paginator); }
public function loadItem($id) { $menuItem = new MenuItem(); $select = $menuItem->select(); $select->from('MenuItemData', array('MID_Style', 'MID_Secured', 'MID_loadImage', 'MID_Show', 'MID_Image', 'MID_ImgAndTitle'))->setIntegrityCheck(false)->joinInner('MenuItemIndex', 'MID_ID = MII_MenuItemDataID', array('MII_Title', 'MII_Link', 'MII_PageID', 'MII_Placeholder'))->where('MII_LanguageID = ?', Zend_registry::get('currentEditLanguage'))->where('MID_ID = ?', $id); $row = $menuItem->fetchRow($select); if ($row) { $isPage = $row['MII_PageID'] != -1; $menuItemType = 'page'; if ($row['MII_Placeholder']) { $menuItemType = 'placeholder'; } if (!empty($row['MII_Link'])) { $menuItemType = 'external'; } $tmp = array('MenuTitle' => $row['MII_Title'] != '' ? $row['MII_Title'] : '', 'MenuLink' => $row['MII_Link'] != '' ? $row['MII_Link'] : '', 'menuItemSecured' => $row['MID_Secured'], 'menuImage' => $row['MID_Image'], 'loadImage' => $row['MID_loadImage'], 'MID_Show' => $row['MID_Show'], 'menuImgAndTitle' => $row['MID_ImgAndTitle'], 'menuItemType' => $menuItemType, 'pagePicker' => $isPage ? $row['MII_PageID'] : '', 'ControllerName' => $isPage ? $this->getControllerNameByID($row['MII_PageID']) : '', 'MenuTitleStyle' => $row['MID_Style']); } else { $tmp = array('MenuTitle' => '', 'MenuLink' => '', 'menuItemSecured' => '', 'menuImage' => '', 'loadImage' => '', 'menuImgAndTitle' => '', 'MenuType' => 'external', 'pagePicker' => '', 'ControllerName' => '', 'MenuTitleStyle' => ''); } return $tmp; }
/** Get paginated list of all searches for admin interface * @param integer $userid the userid * @param integer $page * @return array */ public function getAllSearchesAdmin($page, $userid) { $search = $this->getAdapter(); $select = $search->select()->from($this->_name)->joinLeft('users', 'users.id = searches.userid', array('username'))->order('id DESC'); if (isset($userid)) { $select->where($this->_name . '.userID = ?', $userid); } $paginator = Zend_Paginator::factory($select); $cache = Zend_registry::get('cache'); Zend_Paginator::setCache($cache); if (isset($page) && $page != "") { $paginator->setCurrentPageNumber((int) $page); } $paginator->setItemCountPerPage(20)->setPageRange(10); return $paginator; }
public function getFiltrada($campo, $valor) { $db = Zend_registry::get('db'); $tab = $campo == 'nome' ? 'c' : 't'; $select = $db->select()->from(array('o' => 'operadoras'), array('nome'))->from(array('t' => 'tarifas'))->join(array('tv' => 'tarifas_valores'), 't.codigo = tv.codigo AND o.codigo = t.operadora'); if (!is_null($valor)) { //$select->where(" $tab.". $campo ." like '%". $valor ."%'"); } $stmt = $db->query($select); $arrFiltro = $stmt->fetchAll(); return $arrFiltro; }
public function getChatTypes() { $id = NULL; $type1 = NULL; $stmt = Zend_registry::get('dbh')->prepare('CALL `admin_configs_fetch`(:id, :type)'); $stmt->bindParam(':id', $id, PDO::PARAM_INT); $stmt->bindParam(':type', $type1, PDO::PARAM_STR); $results = array(); $rowCount = 0; try { $stmt->execute(); do { $results[] = $stmt->fetchAll(Zend_Db::FETCH_OBJ); } while ($stmt->nextRowset()); $stmt->closeCursor(); } catch (Zend_Db_Statement_Exception $e) { //die (__LINE__ . ':' . __FILE__ . ':' . $e->getMessage()); if ('HYC00' == $stmt->errorCode()) { $results[] = $stmt->fetchAll(Zend_Db::FETCH_OBJ); } } return $results; }
/** * Return all cities by state * @return Array */ public function getCity($state) { $db = Zend_registry::get('db'); $select = $db->select()->from("ars_cidade", array('name'))->from("ars_ddd", array('estado'))->where("ars_ddd.cidade = ars_cidade.id")->where("ars_ddd.estado = ?", $state)->order("ars_cidade.name"); $stmt = $db->query($select); $cities = $stmt->fetchAll(); return $cities; }