本文整理汇总了PHP中waModel::query方法的典型用法代码示例。如果您正苦于以下问题:PHP waModel::query方法的具体用法?PHP waModel::query怎么用?PHP waModel::query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类waModel
的用法示例。
在下文中一共展示了waModel::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$model_settings = new waAppSettingsModel();
$settings = $model_settings->get($key = array('shop', 'deliveryshop'));
$model = new waModel();
$domains = $model->query("SELECT * FROM site_domain")->fetchAll();
$prices = $model->query("SELECT * FROM shop_deliveryshop_delivery")->fetchAll('domain');
foreach ($domains as $d) {
$tab = explode('.', $d['name']);
$info[$d['name']]['tab_name'] = $tab[0];
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
$change_tpl[$d['name']] = true;
if (!file_exists($template_path)) {
$template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
$change_tpl[$d['name']] = false;
}
$template_content[$d['name']] = file_get_contents($template_path);
unset($template_path);
}
$this->view->assign('info', $info);
$this->view->assign('prices', $prices);
$this->view->assign('change_tpl', $change_tpl);
$this->view->assign('template', $template_content);
$this->view->assign('settings', $settings);
}
示例2: execute
public function execute()
{
$model = new waModel();
$payment_model = new wacabPaymentModel();
$payments = $payment_model->getAll();
$apps_model = new wacabAppsModel();
$apps = $apps_model->getByField('stat', 1, true);
$total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` is not null')->fetchAll();
$plugins_stat = array();
foreach ($apps as $app) {
$app_total = $model->query('SELECT SUM(pay) FROM wacab_payment WHERE `apps_id` = ' . $app['id'])->fetch();
$app_count = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` >= 0 AND `apps_id` = ' . $app['id'])->fetch();
$app_return = $model->query('SELECT COUNT(*) FROM wacab_payment WHERE `pay` < 0 AND `apps_id` = ' . $app['id'])->fetch();
$names = json_decode($app['name'], true);
if ($app['parent'] == 'no_parent' || $app['parent'] == '') {
$pname = $names[0];
} else {
$pname = $names[0] . " (" . $app['parent'] . ")";
}
$plugins_stat[] = array('id' => $app['app_id'], 'total' => $app_total[0], 'name' => $pname, 'count' => $app_count[0], 'return' => $app_return[0]);
}
$this->view->assign('total', $total);
$this->view->assign('apps', $plugins_stat);
$this->setTemplate(wacabHelper::getAppPath() . '/templates/actions/statistic/stat_page.html');
}
示例3: execute
public function execute()
{
$url = waRequest::param('url');
$domain = waRequest::server('HTTP_HOST');
$model = new waModel();
// $main_domain = $model->query("SELECT value FROM wa_app_settings WHERE app_id = 'webasyst' AND name = 'url'")->fetchField();
$app_settings_model = new waAppSettingsModel();
$main_domain = trim(str_replace(array('https', 'http', '://'), '', $app_settings_model->get('webasyst', 'url')), "/");
$data = $model->query("\nSELECT\n shop_deliveryshop_city_description.*\n, shop_deliveryshop_city.city\n, shop_deliveryshop_city.region\nFROM\n shop_deliveryshop_city_description\nLEFT JOIN\n shop_deliveryshop_city ON shop_deliveryshop_city_description.cityCode = shop_deliveryshop_city.cityCode\nLEFT JOIN\n wa_region ON wa_region.code = shop_deliveryshop_city.region AND wa_region.country_iso3='rus'\nWHERE\n (url = '{$url}' OR city = '{$url}')\nAND\n domain IN ('{$domain}', '{$main_domain}')\nLIMIT 1\n ")->fetchAssoc();
// Уменьшаем стоимость доставки на сумму указанную в настройках плагина
$delivery_compensation = $model->query("SELECT price FROM shop_deliveryshop_delivery WHERE domain = '" . $domain . "'")->fetchField();
$delivery_compensation = intval($delivery_compensation);
$delivery_price = intval($data['delivery_price']);
$courier_price = intval($data['courier_price']);
if ($delivery_price > $delivery_compensation) {
$data['delivery_price'] = (int) (($delivery_price - $delivery_compensation) / 50) * 50;
//Уменьшаем до ближайшего полтинника
} else {
$data['delivery_price'] = 0;
}
if ($courier_price > $delivery_compensation) {
$data['courier_price'] = (int) (($courier_price - $delivery_compensation) / 50) * 50;
//Уменьшаем до ближайшего полтинника
} else {
$data['courier_price'] = 0;
}
foreach (array('meta_title' => $main_domain, 'meta_description' => '', 'meta_keywords' => '', 'delivery_time' => '', 'courier_time' => '') as $key => $value) {
$data[$key] = isset($data[$key]) ? $data[$key] : $value;
}
wa()->getResponse()->setTitle($data['meta_title']);
wa()->getResponse()->setMeta('description', $data['meta_description']);
wa()->getResponse()->setMeta('keywords', $data['meta_keywords']);
$city_code = isset($data['cityCode']) ? $data['cityCode'] : 0;
$pvz = $model->query("\nSELECT\n shop_deliveryshop_pvz.*\nFROM\n shop_deliveryshop_pvz\nWHERE\n cityCode = {$city_code}\nAND\n status = 'completed'\nAND\n (domain IN ('{$domain}', '{$main_domain}') OR domain IS NULL)\n")->fetchAll();
//$site_model = new siteDomainModel();
//$domain_id = $site_model->getByName($domain);
$domain_id = $model->query("SELECT id FROM site_domain WHERE name = '" . $domain . "'")->fetchField();
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $domain_id . '.html', false, 'shop', true);
if (!file_exists($template_path)) {
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', false, 'shop', true);
}
if (!file_exists($template_path)) {
$template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
}
$this->view->assign('data', $data);
$this->view->assign('pvz', $pvz);
$this->view->assign('page', array('id' => null, 'name' => '', 'content' => $this->view->fetch($template_path)));
$this->setThemeTemplate('page.html');
waSystem::popActivePlugin();
}
示例4: execute
public function execute()
{
$plugin_id = array('shop', 'deliveryshop');
try {
$app_settings_model = new waAppSettingsModel();
$settings = waRequest::post('settings');
$app_settings_model->set($plugin_id, 'status', (int) $settings['status']);
$model = new waModel();
$domains = $model->query("SELECT * FROM site_domain")->fetchAll();
$reset_tpls = waRequest::post('reset_tpls');
$template = waRequest::post('template');
$prices = waRequest::post('prices');
$this->response['pri'] = $prices;
foreach ($domains as $d) {
$id_price = $model->query("SELECT id FROM shop_deliveryshop_delivery WHERE domain = '" . $d['name'] . "'")->fetchField();
if ($id_price) {
$model->query("UPDATE shop_deliveryshop_delivery SET price = '" . $prices[$d['name']]['price'] . "' WHERE domain = '" . $d['name'] . "'");
} else {
$model->query("INSERT INTO shop_deliveryshop_delivery (domain, price)\n VALUES ('" . $d['name'] . "', '" . $prices[$d['name']]['price'] . "')");
}
if (isset($reset_tpls[$d['name']])) {
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
@unlink($template_path);
} else {
if (!isset($template[$d['name']])) {
throw new waException('Не определён шаблон');
}
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
if (!file_exists($template_path)) {
$template_path = wa()->getAppPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka.html', 'shop');
}
$template_content = file_get_contents($template_path);
if ($template_content != $template[$d['name']]) {
$template_path = wa()->getDataPath('plugins/deliveryshop/templates/actions/frontend/FrontendDostavka' . $d['id'] . '.html', false, 'shop', true);
$f = fopen($template_path, 'w');
if (!$f) {
throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path);
}
fwrite($f, $template[$d['name']]);
fclose($f);
}
}
$this->response['template'] = $template;
}
$this->response['message'] = "Сохранено";
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
示例5: postPublishAction
public function postPublishAction($params)
{
$post_id = (int) $params['id'];
$blog_id = (int) $params['blog_id'];
// check rights for this blog at first and unsubscribe user if he hasn't
$sql = "SELECT c.id FROM blog_emailsubscription s\n JOIN wa_contact c ON s.contact_id = c.id\n WHERE s.blog_id = " . $blog_id;
$model = new waModel();
$unsubscribe_contact_ids = array();
foreach ($model->query($sql) as $row) {
$rights = 1;
try {
$rights = blogHelper::checkRights($blog_id, $row['id'], blogRightConfig::RIGHT_READ);
} catch (Exception $e) {
$rights = 0;
}
if (!$rights) {
$unsubscribe_contact_ids[] = $row['id'];
}
}
if ($unsubscribe_contact_ids) {
$em = new blogEmailsubscriptionModel();
$em->deleteByField(array('contact_id' => $unsubscribe_contact_ids, 'blog_id' => $blog_id));
}
// add subscribers to queue
$sql = "REPLACE INTO blog_emailsubscription_log (post_id, contact_id, name, email, datetime)\n SELECT " . $post_id . ", c.id, c.name, e.email, '" . date('Y-m-d H:i:s') . "' FROM blog_emailsubscription s\n JOIN wa_contact c ON s.contact_id = c.id\n JOIN wa_contact_emails e ON c.id = e.contact_id AND e.sort = 0\n WHERE s.blog_id = " . $blog_id;
$model->exec($sql);
// save backend url for cron
$app_settings_model = new waAppSettingsModel();
$app_settings_model->set(array($this->app_id, $this->id), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
}
示例6: execute
public function execute()
{
try {
$data = waRequest::post();
$model = new waModel();
foreach ($data['data'] as $k => $v) {
if ($v['id'] != 'new') {
$is = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code = '" . $v['id'] . "' AND domain = '" . $k . "'")->fetchAssoc();
if (!$is) {
$d = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code = '" . $v['id'] . "'")->fetchAssoc();
if ($d && $d['domain'] == '') {
$model->query("UPDATE shop_deliveryshop_pvz SET \n address = '" . $v['address'] . "',\n workTime = '" . $v['workTime'] . "',\n email = '" . $v['email'] . "',\n TK = '" . $v['TK'] . "',\n note = '" . $v['note'] . "',\n phone = '" . $v['phone'] . "',\n domain = '" . $k . "'\n WHERE id = '" . $d['id'] . "'");
} else {
$model->query("INSERT INTO shop_deliveryshop_pvz \n (code, name, city, cityCode, workTime, address, phone, note, coordX, coordY, \n weightMin, weightMax, TK, domain, status, email)\n VALUES ('" . $v['id'] . "', '" . $d['name'] . "', '" . $d['city'] . "',\n '" . $d['cityCode'] . "', '" . $v['workTime'] . "',\n '" . $v['address'] . "', '" . $v['phone'] . "', '" . $v['note'] . "',\n '" . $d['coordX'] . "', '" . $d['coordY'] . "', '" . $d['weightMin'] . "',\n '" . $d['weightMax'] . "', '" . $v['TK'] . "', '" . $k . "', '" . $d['status'] . "', '" . $v['email'] . "')");
}
} else {
$model->query("UPDATE shop_deliveryshop_pvz SET \n address = '" . $v['address'] . "',\n workTime = '" . $v['workTime'] . "',\n email = '" . $v['email'] . "',\n TK = '" . $v['TK'] . "',\n note = '" . $v['note'] . "',\n phone = '" . $v['phone'] . "'\n WHERE id = '" . $is['id'] . "' AND domain = '" . $k . "'");
}
} else {
if ($v['city']) {
$city = $model->query("SELECT city FROM shop_deliveryshop_city WHERE cityCode = '" . $v['city'] . "'")->fetchField();
$model->query("INSERT INTO shop_deliveryshop_pvz \n (code, name, city, cityCode, workTime, address, phone, note, coordX, coordY, \n weightMin, weightMax, TK, domain, status, email)\n VALUES ('" . $v['code'] . "', '" . $v['name'] . "', '" . $city . "',\n '" . $v['city'] . "', '" . $v['workTime'] . "',\n '" . $v['address'] . "', '" . $v['phone'] . "', '" . $v['note'] . "',\n '" . $v['coordX'] . "', '" . $v['coordY'] . "', '" . $v['weightMin'] . "',\n '" . $v['weightMax'] . "', '" . $v['TK'] . "', '" . $k . "', 'new', '" . $v['email'] . "')");
} else {
$this->response['stat'] = 'error';
}
}
}
$this->response['message'] = 'ok';
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:32,代码来源:shopDeliveryshopPluginBackendSavepvz.controller.php
示例7: query
protected function query($sql, $one = true)
{
$q = $this->source->query($sql);
if ($one) {
return $q->fetch();
} else {
return $q->fetchAll();
}
}
示例8: execute
public function execute(&$params)
{
$master_id = $params['id'];
$merge_ids = $params['contacts'];
$all_ids = array_merge($merge_ids, array($master_id));
$m = new waModel();
//
// All the simple cases: update contact_id in tables
//
foreach (array(array('shop_cart_items', 'contact_id'), array('shop_checkout_flow', 'contact_id'), array('shop_order', 'contact_id'), array('shop_order_log', 'contact_id'), array('shop_product', 'contact_id'), array('shop_product_reviews', 'contact_id'), array('shop_affiliate_transaction', 'contact_id')) as $pair) {
list($table, $field) = $pair;
$sql = "UPDATE {$table} SET {$field} = :master WHERE {$field} in (:ids)";
$m->exec($sql, array('master' => $master_id, 'ids' => $merge_ids));
}
//
// shop_affiliate_transaction
//
$balance = 0.0;
$sql = "SELECT * FROM shop_affiliate_transaction WHERE contact_id=? ORDER BY id";
foreach ($m->query($sql, $master_id) as $row) {
$balance += $row['amount'];
if ($row['balance'] != $balance) {
$m->exec("UPDATE shop_affiliate_transaction SET balance=? WHERE id=?", $balance, $row['id']);
}
}
$affiliate_bonus = $balance;
//
// shop_customer
//
// Make sure it exists
$cm = new shopCustomerModel();
$cm->createFromContact($master_id);
$sql = "SELECT SUM(number_of_orders) FROM shop_customer WHERE contact_id IN (:ids)";
$number_of_orders = $m->query($sql, array('ids' => $all_ids))->fetchField();
$sql = "SELECT MAX(last_order_id) FROM shop_customer WHERE contact_id IN (:ids)";
$last_order_id = $m->query($sql, array('ids' => $all_ids))->fetchField();
$sql = "UPDATE shop_customer SET number_of_orders=?, last_order_id=?, affiliate_bonus=? WHERE contact_id=?";
$m->exec($sql, ifempty($number_of_orders, 0), ifempty($last_order_id, null), ifempty($affiliate_bonus, 0), $master_id);
if ($number_of_orders) {
shopCustomers::recalculateTotalSpent($master_id);
}
wa('shop')->event('customers_merge', $params);
return null;
}
示例9: execute
public function execute()
{
try {
$id = waRequest::post('id');
$status = waRequest::post('status');
$g = waRequest::post('g');
$model = new waModel();
if ($g == 'shop') {
$model->query("UPDATE shop_deliveryshop_city SET status='" . $status . "' WHERE cityCode='" . $id . "'");
} else {
if ($g == 'delivery') {
$model->query("UPDATE shop_deliveryshop_pvz SET status='" . $status . "' WHERE code='" . $id . "'");
}
}
$this->response['message'] = 'ok';
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
开发者ID:quadrodesign,项目名称:deliveryshop,代码行数:19,代码来源:shopDeliveryshopPluginBackendChangestatus.controller.php
示例10: generateSchema
protected function generateSchema($app_id, $tables = array())
{
$plugin_id = false;
if (strpos($app_id, '/') !== false) {
list($app_id, $plugin_id) = explode('/', $app_id, 2);
$path = wa()->getConfig()->getAppsPath($app_id, 'plugins/' . $plugin_id . '/lib/config/db.php');
} else {
$path = wa()->getConfig()->getAppsPath($app_id, 'lib/config/db.php');
}
if (waRequest::param('update') !== null) {
$schema = (include $path);
if (!$tables) {
$tables = array_keys($schema);
}
} elseif ($tables) {
if (!is_array($tables)) {
$tables = array($tables);
}
} else {
$prefix = $app_id == 'webasyst' ? 'wa' : $app_id;
if ($plugin_id) {
$prefix .= '_' . $plugin_id;
}
// @todo: use db adapter to get tables
$sql = "SHOW TABLES LIKE '" . $prefix . "\\_%'";
$tables = $this->model->query($sql)->fetchAll(null, true);
$sql = "SHOW TABLES LIKE '" . $prefix . "'";
$tables = array_merge($tables, $this->model->query($sql)->fetchAll(null, true));
}
$schema = array();
foreach ($tables as $t) {
echo $t . "\n";
try {
$schema[$t] = $this->model->describe($t, 1);
} catch (waDbException $ex) {
print "\tError: " . $ex->getMessage() . "\n";
}
}
if ($schema) {
// save schema to lib/config/db.php of the app
waUtils::varExportToFile($this->schemaToString($schema), $path, false);
}
}
示例11: getTables
protected function getTables($prefix)
{
// @todo: use db adapter to get tables
$tables = array();
$prefix = $this->model->escape($prefix, 'l');
$sql = "SHOW TABLES LIKE '{$prefix}'";
$tables = array_merge($tables, $this->model->query($sql)->fetchAll(null, true));
$sql = "SHOW TABLES LIKE '{$prefix}\\_%'";
$tables = array_merge($tables, $this->model->query($sql)->fetchAll(null, true));
return $tables;
}
示例12: execute
public function execute()
{
$id = waRequest::post('id');
$name = waRequest::post('name');
$content = waRequest::post('content');
$model = new waModel();
if (is_numeric($id)) {
$model->query("UPDATE shop_notifier_template SET name = '" . $name . "' WHERE id = '" . $id . "'");
} else {
$result = $model->query("INSERT INTO shop_notifier_template (name) VALUES ('" . $name . "')");
$id = $result->lastInsertId();
}
$template_path = shopNotifierPlugin::path($id);
$f = fopen($template_path, 'w');
if (!$f) {
throw new waException('Не удаётся сохранить шаблон. Проверьте права на запись ' . $template_path);
}
fwrite($f, $content);
fclose($f);
$this->response['result'] = array('id' => $id, 'name' => $name);
}
示例13: execute
public function execute()
{
switch (waRequest::get('event')) {
case 'del_trans':
$model = new waModel();
$model->query('TRUNCATE TABLE `wacab_payment`');
break;
case 'del_reviews':
$model = new waModel();
$model->query('TRUNCATE TABLE `wacab_review`');
break;
}
}
示例14: execute
public function execute()
{
$this->setLayout(new shopBackendLayout());
$id = waRequest::get('id');
$model = new waModel();
$city['new'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='new'")->fetchField();
$city['completed'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='completed'")->fetchField();
$city['flag-white'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='flag-white'")->fetchField();
$city['refunded'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz WHERE status='refunded'")->fetchField();
$city['all'] = $model->query("SELECT COUNT(*) FROM shop_deliveryshop_pvz")->fetchField();
$domains = $model->query("SELECT * FROM site_domain")->fetchAll();
if ($id == 'new') {
$description = $model->query("SELECT * FROM shop_deliveryshop_city ORDER BY city ASC")->fetchAll('cityCode');
foreach ($domains as $d) {
$info[$d['name']]['city'] = $description;
$tab = explode('.', $d['name']);
$info[$d['name']]['tab_name'] = $tab[0];
}
} else {
foreach ($domains as $d) {
$description = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code='" . $id . "' AND domain='" . $d['name'] . "'")->fetchAssoc();
if (!$description) {
$description = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE code='" . $id . "'")->fetchAssoc();
}
$description = $description ? $description : array();
$id_city = $description['cityCode'];
$info[$d['name']] = $description;
$tab = explode('.', $d['name']);
$info[$d['name']]['tab_name'] = $tab[0];
}
$pvz['data'] = $model->query("SELECT * FROM shop_deliveryshop_pvz WHERE cityCode = '" . $id_city . "' AND code NOT IN ('" . $id . "')")->fetchAll();
$this->view->assign('pv', $pvz);
}
$this->view->assign('info', $info);
$this->view->assign('id', $id);
$this->view->assign('pvz', $city);
}
示例15: getUserCategoryId
public static function getUserCategoryId($contact_id = null)
{
if ($contact_id === null) {
$contact_id = wa()->getUser()->getId();
}
$model = new waModel();
$sql = "SELECT * FROM `wa_contact_categories` WHERE `contact_id` = '" . $model->escape($contact_id) . "'";
$categories = $model->query($sql)->fetchAll();
$category_ids = array();
$category_ids[] = 0;
foreach ($categories as $category) {
$category_ids[] = $category['category_id'];
}
return $category_ids;
}