Поиск по сайту
Результаты поиска по тегам 'запрос к бд'.
Найдено 5 результатов
-
Всем привет, сайт стал жутко тормозить, нашел медленный запрос Скан. рядов 4468 Получено рядов 1 Время 00:00:37 Текст запроса SELECT COUNT(DISTINCT p.product_id) AS total FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN product_to_category p2c ON (p.product_id = p2c.product_id) WHERE pd.language_id = \'1\' AND p.status = \'1\' AND p.date_available <= NOW() AND p2s.store_id = \'0\' AND (p2c.category_id = \'95\') Ищу исполнителя для оптимизации сего запроса за вознаграждение
- 5 ответов
-
- база данных
- оптимизация
- (и ещё 2)
-
Здравствуйте, можно ли как-то соединить эти запросы таким образом, чтобы через post передавать нужные параметры и эти запрос как-то фильтровать в зависимости от клика по кнопке + или - public function updateLike($product_id) { $this->db->query("SELECT * FROM " . DB_PREFIX . "product SET like_count = (like_count - 1) WHERE product_id = '" . (int)$product_id . "'"); } public function updateLikeMinus($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET like_count = (like_count - 1) WHERE product_id = '" . (int)$product_id . "'"); } public function updateLikePlus($product_id) { $this->db->query("UPDATE " . DB_PREFIX . "product SET like_count = (like_count + 1) WHERE product_id = '" . (int)$product_id . "'"); }
- 3 ответа
-
- запросы к серверу
- запросы к базе данных
- (и ещё 6)
-
Написать скрипт (модуль) который будет запускаться по крону и копировать значения кол-ва товаров quantity из таблицы product в соседнюю таблицу product_to_multistore
- 2 ответа
-
- запрос к бд
- sql
-
(и ещё 4)
Теги:
-
День добрый. Прошу помощи в составлении запроса к БД. По id категории получить seo_url этой категории. Переменная $categories содержит массив с номерами id категорий. В бд таблица url_alias, где столбцы столбцы query (где хранятся урлы вида category_id=номер) и столбец keyword (где прописан алиас).
-
Всем привет! Нуждаюсь в Вашей помощи. Пишу дополнительный заказ товара через аккаунт, проблема в том что не обновляет таблицу БД, с opencart недавно начал разбираться, так что не судите строго. Спасибо! Controller: class ControllerAccountNewOrder extends Controller{ private $error = array(); public function index(){ if (!$this->customer->isLogged()) { $this->redirect($this->url->link('account/login', '', 'SSL')); } $this->language->load('account/new_order'); $this->document->setTitle($this->language->get('heading_title')); $this->load->model('account/neworder'); /*if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) { $this->model_account_neworder->newOrder($this->request->post); //$this->redirect($this->url->link('account/account')); } */ /* load text */ $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_form'] = $this->language->get('text_form'); $this->data['linktopr'] = $this->language->get('linktopr'); $this->data['text_description'] = $this->language->get('text_description'); $this->data['text_color'] = $this->language->get('text_color'); $this->data['text_size'] = $this->language->get('text_size'); $this->data['text_count_product'] = $this->language->get('text_count_product'); $this->data['text_price'] = $this->language->get('text_price'); $this->data['text_sposob'] = $this->language->get('text_sposob'); $this->data['text_delivery_usa'] = $this->language->get('text_delivery_usa'); $this->data['text_hint'] = $this->language->get('text_hint'); $this->data['text_new_pochta'] = $this->language->get('text_new_pochta'); $this->data['text_btn_save'] = $this->language->get('text_btn_save'); $this->data['text_count'] = $this->language->get('text_count'); $this->data['text_comments'] = $this->language->get('text_comments'); $this->data['text_enter_comment'] = $this->language->get('text_enter_comment'); if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $this->data['action'] = $this->url->link('account/new_order', '', 'SSL'); /* data */ if (isset($this->error['forma'])) { $this->data['error_forma'] = $this->error['forma']; } else { $this->data['error_forma'] = ''; } if (isset($this->error['linkto'])) { $this->data['error_linkto'] = $this->error['linkto']; } else { $this->data['error_linkto'] = ''; } if (isset($this->error['description'])) { $this->data['error_description'] = $this->error['description']; } else { $this->data['error_description'] = ''; } if (isset($this->error['color'])) { $this->data['error_color'] = $this->error['color']; } else { $this->data['error_color'] = ''; } if (isset($this->error['sizes'])) { $this->data['error_sizes'] = $this->error['sizes']; } else { $this->data['error_sizes'] = ''; } if (isset($this->error['counts'])) { $this->data['error_counts'] = $this->error['counts']; } else { $this->data['error_counts'] = ''; } if (isset($this->error['tcena'])) { $this->data['error_tcena'] = $this->error['tcena']; } else { $this->data['error_tcena'] = ''; } if (isset($this->request->post['forma'])) { $this->data['forma'] = $this->request->post['forma']; } elseif (isset($customer_info)) { $this->data['forma'] = $customer_info['forma']; } else { $this->data['forma'] = ''; } if (isset($this->request->post['linkto'])) { $this->data['linkto'] = $this->request->post['linkto']; } elseif (isset($customer_info)) { $this->data['linkto'] = $customer_info['linkto']; } else { $this->data['linkto'] = ''; } if (isset($this->request->post['description'])) { $this->data['description'] = $this->request->post['description']; } elseif (isset($customer_info)) { $this->data['description'] = $customer_info['description']; } else { $this->data['description'] = ''; } if (isset($this->request->post['color'])) { $this->data['color'] = $this->request->post['color']; } elseif (isset($customer_info)) { $this->data['color'] = $customer_info['color']; } else { $this->data['color'] = ''; } if (isset($this->request->post['sizes'])) { $this->data['sizes'] = $this->request->post['sizes']; } elseif (isset($customer_info)) { $this->data['sizes'] = $customer_info['sizes']; } else { $this->data['sizes'] = ''; } if (isset($this->request->post['counts'])) { $this->data['counts'] = $this->request->post['counts']; } elseif (isset($customer_info)) { $this->data['counts'] = $customer_info['counts']; } else { $this->data['counts'] = ''; } if (isset($this->request->post['tcena'])) { $this->data['tcena'] = $this->request->post['tcena']; } elseif (isset($customer_info)) { $this->data['tcena'] = $customer_info['tcena']; } else { $this->data['tcena'] = ''; } $this->data['back'] = $this->url->link('account/account', '', 'SSL'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/new_order.tpl')) { $this->template = $this->config->get('config_template') . '/template/account/new_order.tpl'; } else { $this->template = 'default/template/account/new_order.tpl'; } $this->children = array( 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header' ); $this->response->setOutput($this->render()); } public function insert() { $this->load->model('account/neworder'); $this->document->setTitle($this->language->get('heading_title')); if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($this->validateForm())) { $this->model_catalog_news->newOrder($this->request->post); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->url->link('account/new_order', 'token=' . $this->session->data['token'], 'SSL')); } $this->getForm(); } protected function validate() { if ((utf8_strlen($this->request->post['forma']) < 1) || (utf8_strlen($this->request->post['forma']) > 32)) { $this->error['forma'] = $this->language->get('error_forma'); } if ((utf8_strlen($this->request->post['linkto']) < 1) || (utf8_strlen($this->request->post['linkto']) > 32)) { $this->error['linkto'] = $this->language->get('error_linkto'); } if ((utf8_strlen($this->request->post['description']) < 1) || (utf8_strlen($this->request->post['description']) > 32)) { $this->error['description'] = $this->language->get('error_description'); } if ((utf8_strlen($this->request->post['color']) < 1) || (utf8_strlen($this->request->post['color']) > 32)) { $this->error['color'] = $this->language->get('error_color'); } if ((utf8_strlen($this->request->post['sizes']) < 1) || (utf8_strlen($this->request->post['sizes']) > 32)) { $this->error['sizes'] = $this->language->get('error_sizes'); } if ((utf8_strlen($this->request->post['counts']) < 1) || (utf8_strlen($this->request->post['counts']) > 32)) { $this->error['counts'] = $this->language->get('error_counts'); } if ((utf8_strlen($this->request->post['tcena']) < 1) || (utf8_strlen($this->request->post['tcena']) > 32)) { $this->error['tcena'] = $this->language->get('error_tcena'); } if (!$this->error) { return true; } else { return false; } } } Model class ModelAccountNewOrder extends Model{ public function newOrder($data){ $this->db->query("INSERT INTO " . DB_PREFIX . "new_order SET new_order_id = '" . (int)$data['new_order_id'] . "', forma = '" . $this->db->escape($data['forma']) . "', linkto = '" . $this->db->escape($data['linkto']) . "', description = '" . $this->db->escape($data['description']) . "', color = '" . $this->db->escape($data['color']) . "', sizes = '" . $this->db->escape($data['sizes']) . "', counts = '" . (int)$data['counts'] . "', tcena = '" . $this->db->escape($data['tcena']) . "'"); $new_order_id = $this->db->getLastId(); } } view <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data"> <div class="information_page"> <table border="0"> <tr> <th><?php echo $text_form; ?></th> <th><?php echo $linktopr; ?></th> <th><?php echo $text_description; ?></th> <th><?php echo $text_color; ?></th> <th><?php echo $text_size; ?></th> <th><?php echo $text_count_product; ?></th> <th><?php echo $text_price; ?></th> </tr> <tr> <td> <input type="text" name="forma" /> <?php if ($error_forma) { ?> <span class="error"><?php echo $error_forma; ?></span> <?php } ?> </td> <td> <input type="text" name="linkto" /> <?php if ($error_linkto) { ?> <span class="error"><?php echo $error_linkto; ?></span> <?php } ?> </td> <td> <input type="text" name="description" /> <?php if ($error_description) { ?> <span class="error"><?php echo $error_description; ?></span> <?php } ?> </td> <td> <input type="text" name="color" /> <?php if ($error_color) { ?> <span class="error"><?php echo $error_color; ?></span> <?php } ?> </td> <td> <input type="text" name="sizes" /> <?php if ($error_sizes) { ?> <span class="error"><?php echo $error_sizes; ?></span> <?php } ?> </td> <td> <input type="text" name="counts" /> <?php if ($error_counts) { ?> <span class="error"><?php echo $error_counts; ?></span> <?php } ?> </td> <td> <input type="text" name="tcena" /> <?php if ($error_tcena) { ?> <span class="error"><?php echo $error_tcena; ?></span> <?php } ?> </td> </tr> </table> </div> <div class="buttons"> <div class="left"><a href="<?php echo $back; ?>" class="button">Назад</a></div> <div class="right"> <input type="submit" value="Отправить" class="button" /> </div>
