Esempio n. 1
0
 public static function run(IDBFactory $IDBFactory)
 {
     // User表
     $userName = '******';
     $user = $IDBFactory->createUser();
     $user->getDBType();
     $user->insertUser($userName);
     $user->getUser($userName);
     // department表
     $departName = "hahahaha";
     $department = $IDBFactory->createDepartment();
     $user->getDBType();
     $department->insertDepart($departName);
     $department->getDepart($departName);
 }
Esempio n. 2
0
 /**
  * @brief  根据id获取商品信息
  * @param  int    $gid    商品id,多个id时以逗号','分割, 如:2,5,6,21
  * @return array  商品结果集
  */
 public function getGoodsList($gid)
 {
     $fields = ' id , name , goods_no , sell_price , market_price, cost_price , store_nums , img , weight , list_img ';
     $dbObj = IDBFactory::getDB();
     $tableName = IWeb::$app->config['DB']['tablePre'] . 'goods';
     return $dbObj->doSql('SELECT ' . $fields . ' FROM ' . $tableName . ' WHERE id in (' . $gid . ') AND is_del = 0 ');
 }
Esempio n. 3
0
 /**
  * @brief 构造函数
  * @param string $sql 要分页的SQL语句
  * @param int $pagesize 每页的记录
  * @param int $pagelength 展示pageBar的页数
  */
 public function __construct($sql = "", $pagesize = 20, $pagelength = 10)
 {
     $this->pagesize = $pagesize;
     $this->pagelength = $pagelength;
     $this->dbo = IDBFactory::getDB();
     if ($sql != "") {
         $this->setSql($sql);
     }
 }
Esempio n. 4
0
 /**
  * @brief iwebshop14043000版本升级更新
  */
 public function iwebshop14043000()
 {
     $sql = array("ALTER TABLE `{TABLE_PRE}order` ADD `trade_no` VARCHAR(255) NULL COMMENT '支付平台交易号'");
     foreach ($sql as $key => $val) {
         $val = str_replace('{TABLE_PRE}', IWeb::$app->config['DB']['tablePre'], $val);
         IDBFactory::getDB()->query($val);
     }
     die('升级成功!');
 }
Esempio n. 5
0
 /**
  * @brief iwebshop15051500 版本升级更新
  */
 public function iwebshop15051500()
 {
     $sql = array("ALTER TABLE `{pre}regiment` ADD `limit_min_count` int(11) NOT NULL default '0' COMMENT '每人限制最少购买数量'", "ALTER TABLE `{pre}regiment` ADD `limit_max_count` int(11) NOT NULL default '0' COMMENT '每人限制最多购买数量'", "ALTER TABLE `{pre}order` ADD `active_id` int(11) unsigned NOT NULL default '0' COMMENT '促销活动ID'", "INSERT INTO `{pre}payment` VALUES (NULL, '支付宝网银直连', 1, 'bank_alipay', '直接调用银行网关接口,通过网银直接付款,买家无需支付宝账号 <a href=\"http://www.alipay.com/\" target=\"_blank\">立即申请</a>', '/payments/logos/pay_alipay_bank.png', 0, 99, NULL, 0.00, 1, NULL,1);", "INSERT INTO `{pre}payment` VALUES (NULL, '银联在线支付', 1, 'unionpay', '银联unionpay平台接口。<a href=\\'https://open.unionpay.com/ajweb/index\\' target=\\'_blank\\'>立即申请</a>', '/payments/logos/pay_unionpay.png',0, 99, NULL, 0.00, 1, NULL,1);", "INSERT INTO `{pre}payment` VALUES (NULL, '银联支付', 1, 'chinapay', '银联chinapay平台接口。<a href=\\'http://www.chinapay.com/\\' target=\\'_blank\\'>立即申请</a>', '/payments/logos/pay_chinapay.png',0, 99, NULL, 0.00, 1, NULL,1);", "ALTER TABLE `{pre}order` ADD `checkcode` varchar(255) default NULL COMMENT '自提方式的验证码'");
     foreach ($sql as $key => $val) {
         $val = str_replace('{pre}', IWeb::$app->config['DB']['tablePre'], $val);
         IDBFactory::getDB()->query($val);
     }
     die('升级成功!');
 }
Esempio n. 6
0
 function get_table()
 {
     //数据表信息
     $dbObj = IDBFactory::getDB();
     $tableInfo = $dbObj->query('show table status');
     //要渲染的数据
     $renderData = array('tableInfo' => $tableInfo);
     return $renderData;
 }
Esempio n. 7
0
 /**
  * @brief iwebshop15090900 版本升级更新
  */
 public function iwebshop15090900()
 {
     $sql = array("ALTER TABLE `{pre}category` ADD `seller_id` int(11) unsigned  NOT NULL COMMENT '商家ID'", "ALTER TABLE `{pre}ticket` ADD `seller_id` int(11) unsigned  NOT NULL COMMENT '商家ID'", "ALTER TABLE `{pre}prop` ADD `seller_id` int(11) unsigned  NOT NULL COMMENT '商家ID'", "ALTER TABLE `{pre}order_goods` ADD `seller_id` int(11) unsigned  NOT NULL COMMENT '商家ID'", "ALTER TABLE `{pre}promotion` ADD `seller_id` int(11) unsigned  NOT NULL COMMENT '商家ID'", "ALTER TABLE `{pre}bill` ADD `order_ids` text COMMENT 'order表主键ID,结算的ID'", "ALTER TABLE `{pre}order` ADD `seller_id` int(11) unsigned  NOT NULL COMMENT '商家ID'", "ALTER TABLE `{pre}order` ADD `is_checkout` tinyint(1) NOT NULL default '0' COMMENT '是否给商家结算货款 0:未结算;1:已结算'");
     foreach ($sql as $key => $val) {
         $val = str_replace('{pre}', IWeb::$app->config['DB']['tablePre'], $val);
         IDBFactory::getDB()->query($val);
     }
     die('升级成功!');
 }
Esempio n. 8
0
 /**
  * @brief 构造函数,创建数据库对象
  * @param string $tableName 表名称(当多表操作时以逗号分隔,如:user,goods);
  */
 public function __construct($tableName)
 {
     $this->db = IDBFactory::getDB();
     $tablePre = isset(IWeb::$app->config['DB']['tablePre']) ? IWeb::$app->config['DB']['tablePre'] : '';
     //多表处理
     if (stripos($tableName, ',')) {
         $tables = explode(',', $tableName);
         foreach ($tables as $val) {
             if ($this->tableName != '') {
                 $this->tableName .= ',';
             }
             $this->tableName .= $tablePre . trim($val);
         }
     } else {
         $this->tableName = $tablePre . $tableName;
     }
 }
Esempio n. 9
0
 /**
  * @brief 创建对象
  * @return object 数据库对象
  */
 public static function getDB()
 {
     //单例模式
     if (self::$instance != NULL && is_object(self::$instance)) {
         return self::$instance;
     }
     //获取数据库配置信息
     if (!isset(IWeb::$app->config['DB']) || IWeb::$app->config['DB'] == null) {
         throw new IHttpException('can not find DB info in config.php', 1000);
         exit;
     }
     $dbinfo = IWeb::$app->config['DB'];
     //数据库类型
     $dbType = isset($dbinfo['type']) ? $dbinfo['type'] : self::$defaultDB;
     switch ($dbType) {
         default:
             return self::$instance = new IMysql();
             break;
     }
 }
Esempio n. 10
0
 /**
  * 直接发站内信到用户
  * 这个地方直接调用了Mysql的操作类
  * @param $userIds string 用户Id的串
  * @param $content 信件内容 array('title' => '标题','content' => '内容')
  */
 public static function sendToUser($userIds, $content)
 {
     set_time_limit(0);
     //插入$content
     $data = array('title' => IFilter::act($content['title']), 'content' => IFilter::act($content['content'], 'text'), 'time' => date('Y-m-d H:i:s'));
     $msgDB = new IModel("message");
     $msgDB->setData($data);
     $id = $msgDB->add();
     if ($id === false) {
         return false;
     } else {
         $db = IDBFactory::getDB();
         $tableName = IWeb::$app->config['DB']['tablePre'] . "member";
         if ($userIds) {
             $sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},') WHERE user_id in ({$userIds})";
         } else {
             $sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},')";
         }
         return $db->query($sql);
     }
 }
Esempio n. 11
0
 /**
  * @brief 构造函数
  * @param string $name 表名
  */
 public function __construct($name)
 {
     $this->tablePre = isset(IWeb::$app->config['DB']['tablePre']) ? IWeb::$app->config['DB']['tablePre'] : '';
     $this->table = $name;
     $this->dbo = IDBFactory::getDB();
 }
Esempio n. 12
0
 /**
  * @brief 获取添加订单时,商品检索的结果
  */
 public function search_goods()
 {
     //去掉页面的左侧菜单和导航
     $this->layout = '';
     //获取POST数据
     $goods_name = IFilter::act(IReq::get('goods_name'));
     $name_where = IFilter::act(IReq::get('name_where'));
     $goods_code = IFilter::act(IReq::get('goods_code'));
     $code_where = IFilter::act(IReq::get('code_where'));
     $price = IFilter::act(IReq::get('price'));
     $price_where = IFilter::act(IReq::get('price_where'));
     //查询条件
     $where = ' where 1=1 ';
     $where1 = '';
     $where2 = '';
     $where3 = '';
     $where4 = '';
     if ($goods_name) {
         if ($name_where == 'like') {
             $where1 = " and g.name like '%" . $goods_name . "%'";
         } else {
             $where1 = " and g.name = '" . $goods_name . "'";
         }
     }
     if ($goods_code) {
         if ($code_where == 'like') {
             $where2 = " and p.goods_code like '%" . $goods_code . "%'";
         } else {
             $where2 = " and p.goods_code = '" . $goods_code . "'";
         }
     }
     if ($price) {
         if ($price_where == 'like') {
             $where3 = " and p.market_price like '%" . $price . "%'";
             $where4 = " and g.sell_price like '%" . $price . "%'";
         } else {
             $where3 = " and p.market_price = '" . $price . "'";
             $where4 = " and g.sell_price = '" . $price . "'";
         }
     }
     //获得表前缀
     $tablePre = isset(IWeb::$app->config['DB']['tablePre']) ? IWeb::$app->config['DB']['tablePre'] : '';
     //查询商品名称
     $sql = "select distinct * from (select p.goods_id,g.name,p.spec_array,p.id,p.sell_price,p.weight from {$tablePre}goods as g join {$tablePre}products as p on p.goods_id = g.id {$where} {$where1}{$where2}{$where3}\n\t\t\t\tunion all\n\t\t\t\tselect g.id,g.name,g.name='' as aa,g.id='',g.sell_price,g.weight from {$tablePre}goods as g where id not in (select DISTINCT goods_id from {$tablePre}products ) {$where1}{$where4}) b ";
     //获得表链接对象
     $dbo = IDBFactory::getDB();
     //查询结果
     //分页方法
     $page = isset($_GET['page']) ? $_GET['page'] : 1;
     $this->paging = new IPaging($sql);
     $this->arr = $this->paging->getPage($page);
     //查询条件
     $data = array();
     $data['goods_name'] = $goods_name;
     $data['name_where'] = $name_where;
     $data['goods_code'] = $goods_code;
     $data['code_where'] = $code_where;
     $data['price'] = $price;
     $data['price_where'] = $price_where;
     //向前台渲染数据
     $this->setRenderData($data);
     $this->redirect('search_goods');
 }
Esempio n. 13
0
 function createStructure($name)
 {
     //创建数据库对象
     $dbObj = IDBFactory::getDB();
     //获取$name表信息
     $tableInfoArray = $dbObj->query('SHOW TABLE STATUS WHERE Name = \'' . $name . '\'');
     $tableInfo = $tableInfoArray[0];
     //获取$name表的字段信息
     $columnInfo = $dbObj->query('SHOW FULL COLUMNS FROM `' . $name . '`');
     $columnNum = count($columnInfo);
     //SQL初始化拼接字符串
     $bakContent = "DROP TABLE IF EXISTS `" . $name . "`;\r\n CREATE TABLE `" . $name . "` (\r\n";
     //SQL拼接$name表的字段信息
     foreach ($columnInfo as $key => $value) {
         //SQL字段和类型
         $bakContent .= '`' . $value['Field'] . '` ' . $value['Type'];
         //SQL是否为空
         $bakContent .= $value['Null'] === 'NO' ? ' NOT NULL ' : ' NULL ';
         //SQL索引
         if ($value['Key']) {
             switch ($value['Key']) {
                 case "PRI":
                     $bakContent .= ' PRIMARY KEY ';
                     break;
                 case "MUL":
                     $bakContent .= '';
                     break;
                 case "UNI":
                     $bakContent .= ' UNIQUE KEY ';
                     break;
             }
         }
         //SQL默认值
         if ($value['Default'] != '') {
             $bakContent .= ' DEFAULT ' . $value['Default'];
         } else {
             if ($value['Null'] === 'YES' && $value['Default'] == NULL) {
                 $bakContent .= ' DEFAULT NULL ';
             }
         }
         //SQL额外
         $bakContent .= $value['Extra'] == null ? '' : $value['Extra'];
         //SQL注释
         $bakContent .= $value['Comment'] == null ? '' : ' COMMENT \'' . addslashes($value['Comment']) . '\'';
         $bakContent .= $key + 1 == $columnNum ? '' : ",\r\n";
     }
     //SQL字段结构结束
     $bakContent .= "\r\n )";
     //SQL拼接$name表信息
     $bakContent .= $tableInfo['Engine'] !== null ? ' ENGINE=' . $tableInfo['Engine'] : '';
     if ($tableInfo['Collation'] != null) {
         $collation = explode('_', $tableInfo['Collation']);
         $charset = $collation[0];
     } else {
         $charset = '';
     }
     $bakContent .= $charset ? ' CHARSET=' . $charset : '';
     $bakContent .= $tableInfo['Comment'] !== null ? ' COMMENT=\'' . $tableInfo['Comment'] . '\'' : '';
     $bakContent .= $tableInfo['Auto_increment'] !== null ? ' AUTO_INCREMENT=' . $tableInfo['Auto_increment'] : '';
     $bakContent .= ";\r\n\r\n";
     return $bakContent;
 }
Esempio n. 14
0
 /**
  * 直接发站内信到用户
  *
  * 这个地方直接调用了Mysql的操作类
  *
  * @param $update_where where语句
  * @param $content 信件内容
  */
 public static function sendToUser($update_where, $content)
 {
     set_time_limit(0);
     //插入$content
     $arr = array();
     $arr['title'] = IFilter::act($content['title']);
     $arr['content'] = IFilter::act($content['content'], 'text');
     $arr['content'] = addslashes($arr['content']);
     $arr['time'] = date('Y-m-d H:i:s');
     $tb = new IModel("message");
     $tb->setData($arr);
     $id = $tb->add();
     if ($id === false) {
         return false;
     } else {
         $db = IDBFactory::getDB();
         $tableName = IWeb::$app->config['DB']['tablePre'] . "member";
         $sql = "UPDATE `{$tableName}` SET message_ids = CONCAT( IFNULL(message_ids,'') ,'{$id},') WHERE {$update_where}";
         return $db->query($sql);
     }
 }
Esempio n. 15
0
    ?>
</a>
			<?php 
}
?>
			</span>
		</div>

		<div id="admin_left">
			<ul class="submenu"></ul>
			<div id="copyright"></div>
		</div>

		<div id="admin_right">
			<?php 
$dbObj = IDBFactory::getDB();
$tableInfo = $dbObj->query('show table status');
?>
<div class="headbar">
	<div class="position"><span>工具</span><span>></span><span>数据库管理</span><span>></span><span>备份数据库</span></div>
	<div class="operating">
		<a href="javascript:void(0)" onclick="selectAll('name[]');"><button class="operating_btn" type="button"><span class="sel_all">全选</span></button></a>
		<a href="javascript:void(0)" onclick="confirm('确定要备份么?','backup_act()');"><button class="operating_btn" type="button"><span class="backup">备份</span></button></a>
	</div>
	<div class="field">
		<table class="list_table">
			<col width="50px" />
			<col width="200px" />
			<col width="110px" />
			<col width="105px" />
			<col width="150px" />