当前位置: 首页>>代码示例>>PHP>>正文


PHP waModel::exec方法代码示例

本文整理汇总了PHP中waModel::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP waModel::exec方法的具体用法?PHP waModel::exec怎么用?PHP waModel::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在waModel的用法示例。


在下文中一共展示了waModel::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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());
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:30,代码来源:blogEmailsubscriptionPlugin.class.php

示例2: 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;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:44,代码来源:contacts.merge.handler.php

示例3: execute

 public function execute(&$params)
 {
     $master_id = $params['id'];
     $merge_ids = $params['contacts'];
     $m = new waModel();
     foreach (array(array('blog_comment', '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));
     }
     return null;
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:12,代码来源:contacts.merge.handler.php

示例4: postPublishAction

 public function postPublishAction($params)
 {
     $post_id = (int) $params['id'];
     $blog_id = (int) $params['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 = new waModel();
     $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());
 }
开发者ID:nowaym,项目名称:webasyst-framework,代码行数:12,代码来源:blogEmailsubscriptionPlugin.class.php

示例5: array

<?php

$sqls = array();
$sqls[] = 'ALTER TABLE  `blog_comment` CHANGE  `email`  `email` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
$sqls[] = 'ALTER TABLE  `blog_comment` CHANGE  `name`  `name` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
$sqls[] = 'ALTER TABLE  `blog_comment` CHANGE  `site`  `site` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
$sqls[] = 'ALTER TABLE  `blog_post` CHANGE  `text`  `text` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL';
$model = new waModel();
foreach ($sqls as $sql) {
    try {
        $model->exec($sql);
    } catch (Exception $ex) {
        if (class_exists('waLog')) {
            waLog::log(basename(__FILE__) . ': ' . $ex->getMessage(), 'blog-update.log');
        }
    }
}
开发者ID:Lazary,项目名称:webasyst,代码行数:17,代码来源:1337009256.php

示例6: waModel

<?php

$model = new waModel();
try {
    $model->query("SELECT type FROM shop_affiliate_transaction WHERE 0");
} catch (waDbException $e) {
    $model->exec("ALTER TABLE shop_affiliate_transaction ADD type VARCHAR (32) NULL DEFAULT NULL");
    // order_bonus
    $model->exec("UPDATE shop_affiliate_transaction SET type='order_bonus'\n                  WHERE type IS NULL AND order_id IS NOT NULL AND amount > 0");
    // deposit
    $model->exec("UPDATE shop_affiliate_transaction SET type='deposit'\n                  WHERE type IS NULL AND order_id IS NULL AND amount > 0");
    // order_cancel
    $model->exec("UPDATE shop_affiliate_transaction SET type='order_cancel'\n                  WHERE type IS NULL AND order_id IS NOT NULL AND (comment IS NULL OR comment = '') AND amount < 0");
    // order_discount
    $model->exec("UPDATE shop_affiliate_transaction SET type='order_discount'\n                  WHERE type IS NULL AND order_id IS NOT NULL AND amount < 0");
    // withdrawal
    $model->exec("UPDATE shop_affiliate_transaction SET type='withdrawal'\n                  WHERE type IS NULL AND order_id IS NULL AND amount < 0");
}
开发者ID:Lazary,项目名称:webasyst,代码行数:18,代码来源:1400504207.php

示例7: waModel

<?php

$model = new waModel();
$plugin_model = new shopPluginModel();
$plugings = $plugin_model->getByField('plugin', 'invoicejur', true);
if ($plugings) {
    foreach ($plugings as $p) {
        $settings = $model->query("SELECT name, value FROM shop_plugin_settings WHERE id = i:0", $p['id'])->fetchAll('name', true);
        $company = !empty($settings['cust_company']) ? $settings['cust_company'] : 'company';
        $inn = !empty($settings['cust_inn']) ? $settings['cust_inn'] : 'inn';
        $model->exec("UPDATE shop_order_params SET name = 'payment_params_" . $company . "' WHERE name = 'billing_" . $company . "'");
        $model->exec("UPDATE shop_order_params SET name = 'payment_params_" . $inn . "' WHERE name = 'billing_" . $inn . "'");
    }
}
开发者ID:Lazary,项目名称:webasyst,代码行数:14,代码来源:1366967653.php

示例8: waModel

<?php

$model = new waModel();
try {
    $model->query("SELECT moderation FROM `photos_photo` WHERE 0");
} catch (waException $e) {
    // 0 - waited
    // 1 - approved
    // -1 - declined
    $sql = "ALTER TABLE `photos_photo` ADD COLUMN moderation TINYINT(1) NOT NULL DEFAULT 1";
    $model->query($sql);
}
try {
    $model->query("SELECT `votes_count` FROM `photos_photo` WHERE 0");
} catch (waException $e) {
    $model->exec("ALTER TABLE `photos_photo` ADD COLUMN votes_count INT(11) NOT NULL DEFAULT 0");
}
$contact_id = wa()->getUser()->getId();
$photo_model = new photosPhotoModel();
$data = array();
foreach ($photo_model->select('id, rate')->where('rate > 0')->fetchAll() as $item) {
    $data[] = array('photo_id' => $item['id'], 'contact_id' => $contact_id, 'rate' => $item['rate'], 'datetime' => date('Y-m-d H:i:s'), 'ip' => waRequest::getIp(true));
}
$vote_model = new photosPublicgalleryVoteModel();
$vote_model->multipleInsert($data);
$model->exec("UPDATE `photos_photo` SET votes_count = 1 WHERE rate > 0");
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:26,代码来源:install.php

示例9: waModel

<?php

$mod = new waModel();
$mod->exec("UPDATE wa_contact_data SET field='address:region' WHERE field='address:state'");
开发者ID:Lazary,项目名称:webasyst,代码行数:4,代码来源:1355231417.php

示例10: waModel

<?php

$model = new waModel();
try {
    $model->exec("ALTER TABLE shop_order_log ADD INDEX `order_id` (`order_id`)");
} catch (waDbException $e) {
}
try {
    $model->exec("ALTER TABLE shop_order_items DROP INDEX product");
} catch (waDbException $e) {
}
try {
    $model->exec("ALTER TABLE shop_order_items ADD INDEX product_order (product_id, order_id)");
} catch (waDbException $e) {
}
try {
    $model->exec("ALTER TABLE shop_order_items ADD INDEX `order_type` (`order_id`, `type`)");
} catch (waDbException $e) {
}
try {
    $model->exec("ALTER TABLE shop_product_features DROP INDEX sku");
} catch (waDbException $e) {
}
try {
    $model->exec("ALTER TABLE shop_product_features ADD INDEX product_feature (product_id, feature_id, feature_value_id)");
} catch (waDbException $e) {
}
开发者ID:Lazary,项目名称:webasyst,代码行数:27,代码来源:1382692277.php

示例11: waModel

<?php

$model = new waModel();
$model->exec("CREATE TABLE IF NOT EXISTS `wa_contact_field_values` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `parent_field` varchar(64) NOT NULL,\n  `parent_value` varchar(255) NOT NULL,\n  `field` varchar(64) NOT NULL,\n  `value` varchar(255) NOT NULL,\n  `sort` int(11) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`),\n  KEY `parent_field` (`parent_field`,`parent_value`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8");
开发者ID:Lazary,项目名称:webasyst,代码行数:4,代码来源:1357893789.php

示例12: waModel

<?php

$model = new waModel();
try {
    $model->exec("ALTER TABLE `checklists_list` CHANGE `color_class` `color_class` VARCHAR(32) NOT NULL DEFAULT 'c-white'");
} catch (waDbException $e) {
}
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:7,代码来源:1311166561.php

示例13: waModel

<?php

$model = new waModel();
$model->exec("CREATE TABLE IF NOT EXISTS `shop_product_features_selectable` (\n  `product_id` int(11) NOT NULL,\n  `feature_id` int(11) NOT NULL,\n  `value_id` int(11) NOT NULL,\n  PRIMARY KEY (`product_id`,`feature_id`,`value_id`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
开发者ID:Lazary,项目名称:webasyst,代码行数:4,代码来源:1364886085.php

示例14: waModel

<?php

$model = new waModel();
try {
    $model->query("SELECT route FROM shop_category WHERE 0");
} catch (waDbException $e) {
    $model->exec("ALTER TABLE shop_category ADD route VARCHAR(255) NULL DEFAULT NULL");
}
开发者ID:Lazary,项目名称:webasyst,代码行数:8,代码来源:1365678925.php

示例15: waModel

<?php

$mod = new waModel();
try {
    $mod->exec("SELECT fav_sort FROM wa_region LIMIT 0");
} catch (waDbException $e) {
    $mod->exec("ALTER TABLE `wa_region` ADD `fav_sort` INT NULL DEFAULT NULL");
}
try {
    $mod->exec("SELECT fav_sort FROM wa_country LIMIT 0");
} catch (waDbException $e) {
    $mod->exec("ALTER TABLE `wa_country` ADD `fav_sort` INT NULL DEFAULT NULL");
}
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:13,代码来源:1361531415.php


注:本文中的waModel::exec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。