コード例 #1
0
 public function index()
 {
     $ex_mod = D('exchange_goods');
     //搜索
     $where = '1=1 AND status=1 AND (begin_time <= ' . time() . ' OR begin_time = 0) AND (end_time >= ' . time() . ' OR end_time = 0)';
     import("ORG.Util.Page");
     $count = $ex_mod->where($where)->count();
     $p = new Page($count, 20);
     $ex_list = $ex_mod->field('id,img,name,stock,buy_count,user_num,integral')->where($where)->limit($p->firstRow . ',' . $p->listRows)->order('sort asc')->select();
     $page = $p->show();
     $this->assign('page', $page);
     $this->seo['seo_title'] = '积分兑换';
     $this->seo['seo_title'] = $this->seo['seo_title'] . ' - ' . $this->setting['site_name'];
     $this->seo['seo_keys'] = '积分兑换';
     $this->seo['seo_desc'] = '积分兑换';
     $this->assign('ex_list', $ex_list);
     $this->assign('seo', $this->seo);
     $model = new Model();
     //积分排行
     $integral_sql = 'select a.id as id,a.name as name, b.integral as integral from ' . C('DB_PREFIX') . 'user as a left join ' . C('DB_PREFIX') . 'user_info as b on a.id=b.uid order by b.integral desc limit 0,10';
     $top10integral = $model->query($integral_sql);
     //兑换排行
     $ex_sql = 'select a.id as id,a.name as name, b.exchange_num as exchange_num from ' . C('DB_PREFIX') . 'user as a left join ' . C('DB_PREFIX') . 'user_info as b on a.id=b.uid order by b.integral desc limit 0,10';
     $top10ex = $model->query($ex_sql);
     $this->assign('top10integral', $top10integral);
     $this->assign('top10ex', $top10ex);
     //获取seo信息
     $this->nav_seo('exchange_goods', 'nav', 5);
     $this->display();
 }
コード例 #2
0
 function getLastId()
 {
     $Model = new Model();
     $Model->query("select last_insert_id() as last");
     $result = $Model->query("select last_insert_id() as last");
     return $result[0]["last"];
 }
コード例 #3
0
ファイル: toolsEvent.class.php プロジェクト: google2013/p2c
 function bonus($funds, $id = 0)
 {
     if (!$id) {
         return array("status" => 0, "info" => "请提供ID");
     }
     if (!$funds) {
         return array("status" => 0, "info" => "请提供要分配的资金");
     }
     $mod = new Model();
     $field = " a.id , a.uid,a.username,c.id as gid,c.catpid as gcatpid , c.name";
     $sql = "select " . $field . "  from ds_user as a  right  join ds_user_commision as b on a.uid = b.uid  right join ds_commision as c on  b.group_id = c.id where a.id=" . $id . " limit 1";
     $list = $mod->query($sql);
     $ret = array('source_id' => $list[0]['id'], 'source_name' => $list[0]['username']);
     $ret['funds'] = $funds;
     $ret['list'] = array();
     if (!$list) {
         return array("info" => "没有分成");
     }
     $in = explode('-', $list[0]['gcatpid']);
     $in = implode(",", $in);
     $field = " a.bonus,a.level,a.ratio,a.id as gid ,b.uid ,c.username";
     $sql = "select " . $field . "  from ds_commision as a  left  join ds_user_commision as b on a.id = b.group_id  left join ds_user as c on  b.uid = c.id ";
     $sql .= "where a.id in(" . $in . ") order by a.level";
     $list = $mod->query($sql);
     foreach ($list as $k => $v) {
         if (intval($v['level']) == 1) {
             $ret['webBonus'] = $v['bonus'];
             $ret['webProfit'] = intval($funds) * floatval($v['bonus']);
         } else {
             $ret['list'][$k] = $v;
             $ret['list'][$k]['profit'] = ($funds - $ret['webProfit']) * floatval($v['bonus']);
         }
     }
     return $ret;
 }
コード例 #4
0
ファイル: TopicImageAction.class.php プロジェクト: macall/jsd
 public function delete()
 {
     $id = intval($_REQUEST['id']);
     $tid = intval($_REQUEST['tid']);
     $data = M("TopicImage")->getById($id);
     if (!$data) {
         $this->ajaxReturn(l("IMAGE_NOT_EXIST"), "", 0);
     }
     $info = $data['topic_id'] . l("TOPIC_IMAGE");
     //		@unlink(APP_ROOT_PATH.$data['path']);
     //		@unlink(APP_ROOT_PATH.$data['o_path']);
     $list = M("TopicImage")->where("id=" . $id)->delete();
     if ($list !== false) {
         $Model = new Model();
         $img_array = $Model->query("select path,o_path,width,height,id,name from " . DB_PREFIX . "topic_image where topic_id=" . $tid);
         $count_img = count($img_array);
         if ($count_img > 0) {
             $is_img = 1;
         } else {
             $is_img = 0;
         }
         $img_cache = serialize($img_array);
         $Model->query("update " . DB_PREFIX . "topic set image_list = '" . $img_cache . "' ,has_img=" . $is_img . " ,image_count=" . $count_img . " where id = " . $tid);
         save_log($info . l("DELETE_SUCCESS"), 0);
         $this->ajaxReturn("", "", 1);
     } else {
         save_log($info . l("删除图片失败"), 0);
         $this->error(l("DELETE_FAILED"), $ajax);
     }
 }
コード例 #5
0
ファイル: OrderModel.class.php プロジェクト: macall/ldh
 public function get_order_list($offset = 0, $limit = '')
 {
     $model = new Model();
     $sql = "SELECT \n                    user_order.`order_id`,\n                    user_order.`user_id`,\n                    ldh_user.`name` AS user_name,\n                    user_order.`product`,\n                    user_order.`remark`,\n                    CONCAT(\n                      user_order.`province`,\n                      user_order.`city`,\n                      user_order.`dist`,\n                      user_order.`address`\n                    ) AS buyer_address,\n                    user_order.`tel`,\n                    user_order.`qq`,\n                    user_order.`uname`,\n                    user_order.`message`,\n                    user_order.`created_at`,\n                    user_order.`status` \n                FROM\n                    ldh_order AS user_order \n                LEFT \n                    JOIN ldh_user \n                ON \n                    user_order.`user_id` = ldh_user.`user_id` \n                ORDER BY \n                    user_order.`status` ASC, \n                    user_order.`created_at` DESC";
     if (!empty($limit)) {
         $sql .= ' limit %d,%d';
         return $model->query($sql, array($offset, $limit));
     }
     return $model->query($sql);
 }
コード例 #6
0
ファイル: SystemAction.class.php プロジェクト: SubDong/pigcms
 public function _needUpdate()
 {
     $Model = new Model();
     $Model->query("CREATE TABLE IF NOT EXISTS `" . C('DB_PREFIX') . "system_info` (`lastsqlupdate` INT( 10 ) NOT NULL ,`version` VARCHAR( 10 ) NOT NULL) ENGINE = MYISAM CHARACTER SET utf8");
     $Model->query("CREATE TABLE IF NOT EXISTS `" . C('DB_PREFIX') . "update_record` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `msg` varchar(600) NOT NULL DEFAULT '',\n  `type` varchar(20) NOT NULL DEFAULT '',\n  `time` int(10) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`)\n) ENGINE=MYISAM DEFAULT CHARSET=utf8");
     $updateRecord = M('System_info')->order('lastsqlupdate DESC')->find();
     $key = $this->key;
     $url = $this->server_url . 'server.php?key=' . $key . '&lastversion=' . $updateRecord['version'] . '&domain=' . base64_encode(C('site_url'));
     $remoteStr = file_get_contents($url);
     $rt = json_decode($remoteStr, 1);
     return $rt;
 }
コード例 #7
0
ファイル: Todo.php プロジェクト: kmiksi/frameworkless
 public function finish($id = null)
 {
     if (!empty($id)) {
         $result = $this->Model->query('UPDATE todos SET finished = :finished WHERE id = :id', array(':id' => $id, ':finished' => date('c')));
         if ($result === FALSE) {
             $message = 'ERROR: Error updating data, please try again.';
         } else {
             $message = 'SUCCESS!';
         }
     }
     $this->set(compact('message'));
     $this->index();
     $this->render('index');
 }
コード例 #8
0
ファイル: IndexModel.class.php プロジェクト: redisck/xiangmu
 function get_time_sail_info()
 {
     $sail = new Model();
     $sql = "select t.id,t.classify_id,t.goods_id,t.price,t.rebate_price,t.start_time,t.end_time,t.status,\r\t\t\t\tg.reserve,g.name,g.image,g.author,g.qd_id,g.press from qd_goods as g,qd_time_sail as t where g.id=t.goods_id order by t.status desc limit 1";
     $info = $sail->query($sql);
     return $info;
 }
コード例 #9
0
ファイル: searchModel.class.php プロジェクト: ndusan/belvi
	public function getResults($params){
		
		if(isset($params['s_accomodation_type_id']) && $params['s_accomodation_type_id'] > 0 && isset($params['s_transport_id']) && $params['s_transport_id'] > 0){
			$query = sprintf("SELECT `accomodations`.*,
								`accomodation_types`.`name` AS `accmodation_type`, `accomodation_types`.`accomodation`, `accomodation_types`.`link_name` AS `accomodation_type_link`
								FROM `accomodations` 
								INNER JOIN `accomodation_types` ON `accomodation_types`.`id`=`accomodations`.`accomodation_type_id`
								INNER JOIN `accomodation_type_transport` ON `accomodation_type_transport`.`accomodation_type_id`=`accomodation_types`.`id`
								WHERE 	`accomodation_types`.`id`='%s' AND
										`accomodation_type_transport`.`transport_id`='%s'",
							mysql_real_escape_string($params['s_accomodation_type_id']),
							mysql_real_escape_string($params['s_transport_id'])
							);
			
		}elseif(isset($params['s_accomodation_type_id']) && $params['s_accomodation_type_id'] > 0){
			$query = sprintf("SELECT `accomodations`.*,
								`accomodation_types`.`name` AS `accmodation_type`, `accomodation_types`.`accomodation`, `accomodation_types`.`link_name` AS `accomodation_type_link`
								FROM `accomodations` 
								INNER JOIN `accomodation_types` ON `accomodation_types`.`id`=`accomodations`.`accomodation_type_id`
								WHERE 	`accomodation_types`.`id`='%s'",
							mysql_real_escape_string($params['s_accomodation_type_id'])
							);
			
		}else return false;
		return parent::query($query);
	}
コード例 #10
0
	public function getHotels($params){
		
		$query = sprintf("SELECT * FROM `accomodations` WHERE `accomodation_type_id`='%s' GROUP BY `id`",
						mysql_real_escape_string($params['id'])
						);
		return parent::query($query);
	}
コード例 #11
0
ファイル: OrderAction.class.php プロジェクト: redisck/xiangmu
 public function detail()
 {
     $this->init();
     $orderid = $_GET['id'];
     //dump($orderid);
     //订单表值
     $order = M("order");
     $orders = $order->where("id=" . $orderid)->select();
     $num = explode(',', $orders[0]['goods_num']);
     //下单人
     $user = M("user");
     $users = $user->where("id=" . $orders[0]['user_id'])->getField('username');
     //地址表值
     $address = M("address");
     $addresses = $address->where("id=" . $orders[0]['address_id'])->select();
     //订单中多个商品
     $goodid = $orders[0]['goods_id'];
     $good = new Model();
     $goods = $good->query("select name,qd_price,image from qd_goods where id in ({$goodid})");
     foreach ($goods as $key => $val) {
         $goods[$key]['num'] = $num[$key];
         $arr = explode('_', $val['image']);
         $goods[$key]['path1'] = $arr[0];
         $goods[$key]['path2'] = $arr[1];
         $goods[$key]['root'] = C('Goods_image_path');
     }
     //发送值
     $this->assign("goods", $goods);
     $this->assign("orders", $orders);
     $this->assign("users", $users);
     $this->assign("addresses", $addresses);
     $this->display();
 }
コード例 #12
0
ファイル: statistFunc.php プロジェクト: ReadYun/vixik
function userInfoCompleteStats($survey_code)
{
    $model = new Model();
    $sql = "select\n                count(*) all_cnt ,\n                sum(case when a.question_prop='radio' then 1 else 0 end) radio_cnt ,\n                sum(case when a.question_prop='checkbox' then 1 else 0 end) checkbox_cnt ,\n                sum(case when a.question_prop='textarea' then 1 else 0 end) textarea_cnt\n            from tb_bas_question_info a , tb_bas_survey_question <b></b>    \n            where a.question_code=b.question_code\n            and b.survey_code='{$survey_code}'";
    $svCnt = $model->query($sql);
    return $svCnt;
}
コード例 #13
0
ファイル: PriceModel.class.php プロジェクト: macall/ldh
 public function get_price_base_info()
 {
     $model = new Model();
     $sql = 'SELECT 
                 total_search.total,
                 used_search.used,
                 unsed_search.unused 
               FROM
                 (SELECT 
                   COUNT(ldh_price.price_id) AS total 
                 FROM
                   ldh_price WHERE is_valid = 1) AS total_search 
               ,
               (SELECT 
                 COUNT(ldh_price.price_id) AS used 
               FROM
                 ldh_price 
               WHERE STATUS = 2 AND is_valid = 1) AS used_search 
               ,
               (SELECT 
                 COUNT(ldh_price.price_id) AS unused 
               FROM
                 ldh_price 
               WHERE STATUS = 1 AND is_valid = 1) AS unsed_search';
     return $model->query($sql);
 }
コード例 #14
0
ファイル: db_model.php プロジェクト: hubs/yuncms
 public function sql_query($sql)
 {
     if (!empty($this->prefix)) {
         $sql = str_replace('#dbprefix#', $this->prefix, $sql);
     }
     return parent::query($sql);
 }
コード例 #15
0
 private function imdata($filename)
 {
     $Boolean = preg_match("/_part/", $filename);
     $datadir = 'backupdata/';
     if ($Boolean) {
         $fn = explode("_part", $filename);
         $backup = scandir($datadir);
         for ($i = 0; $i < count($backup); $i++) {
             $part = preg_match("/{$fn[0]}/", $backup[$i]);
             if ($part) {
                 $filenames[] = $backup[$i];
             }
         }
     }
     if (is_array($filenames)) {
         foreach ($filenames as $fn) {
             $data .= file_get_contents($datadir . $fn);
             //获取数据
         }
     } else {
         $data = file_get_contents($datadir . $filename);
     }
     $data = str_replace("\r", "\n", $data);
     $regular = "/;\n/";
     $data = preg_split($regular, trim($data));
     $obj = new Model();
     foreach ($data as $val) {
         $obj->query($val);
     }
     return true;
 }
コード例 #16
0
 public function get_list($lat, $long, $page, $pagesize, $activity_type)
 {
     $where = array("status" => 0, "invite_time" => array("gt", time()));
     if ($activity_type !== false) {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.activity_type=" . $activity_type . " AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
         $where["activity_type"] = intval($activity_type);
     } else {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
     }
     $start = ($page - 1) * $pagesize;
     $count = $this->where($where)->count();
     $sql .= " limit {$start}, {$pagesize}";
     $mode = new Model();
     $res = $mode->query($sql);
     $today = strtotime(date("Y-m-d")) + 86400;
     $tomorrow = $today + 86400;
     $lastday = $tomorrow + 86400;
     foreach ($res as &$v) {
         $v["_time"] = date("Y-m-d H:i", $v["invite_time"]);
         $v["juli"] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($lat * PI() / 180 - $v["lat"] * PI() / 180) / 2), 2) + COS($lat * PI() / 180) * COS($v["lat"] * PI() / 180) * POW(SIN(($long * PI() / 180 - $v["long"] * PI() / 180) / 2), 2))) * 1000);
         $v["juli"] = 1000 < $v["juli"] ? number_format($v["juli"] / 1000, 1) . "km" : ($v["juli"] < 100 ? "<100m" : $v["juli"] . "m");
         $v["invite_time"] = $v["invite_time"] < $today ? "今天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $tomorrow ? "明天  " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $lastday ? "后天  " . date("H:i", $v["invite_time"]) : date("m-d H:i", $v["invite_time"])));
         $v["birthday"] && ($v["age"] = date("Y") - date("Y", strtotime($v["birthday"])));
         $v["age"] = 100 < $v["age"] || $v["age"] < 0 ? "保密" : $v["age"] . "岁";
     }
     return array("data" => $res, "total" => $count);
 }
コード例 #17
0
ファイル: model.php プロジェクト: obscurun/run-dev
 public static function getInstance($id = false)
 {
     if (!$id) {
         foreach (self::$connectionData as $k => $v) {
             $idC = $k;
             break;
         }
     } else {
         $idC = $id;
     }
     $connection = Model::getConnectionData($idC);
     $database = NULL;
     // Debug::print_r("getInstance $id ", $connection);
     if (Run::MYSQL === true && $connection['type_db'] == "mysql") {
         $database = Mysql::getInstance($id);
         if ($id) {
             Mysql::setActive($id);
         }
         self::$query = new MysqlQuery($id);
         return $database;
     } else {
         if (Run::POSTGRE === true && $connection['type_db'] == "postgre") {
             $database = Postgre::getInstance($id);
             if ($id) {
                 Postgre::setActive($id);
             }
             self::$query = new PostgreQuery($id);
             return $database;
         } else {
             return false;
         }
     }
 }
コード例 #18
0
ファイル: slug.php プロジェクト: ClixLtd/pccupload
 /**
  * Creates a unique slug and adds it to the object
  *
  * @param  Model  Model object subject of this observer method
  */
 public function before_insert(Model $obj)
 {
     // determine the slug
     $properties = (array) $this->_source;
     $source = '';
     foreach ($properties as $property) {
         $source .= '-' . $obj->{$property};
     }
     $slug = \Inflector::friendly_title(substr($source, 1), '-', true);
     // query to check for existence of this slug
     $query = $obj->query()->where($this->_property, 'like', $slug . '%');
     // is this a temporal model?
     if ($obj instanceof Model_Temporal) {
         // add a filter to only check current revisions excluding the current object
         $class = get_class($obj);
         $query->where($class::temporal_property('end_column'), '=', $class::temporal_property('max_timestamp'));
         foreach ($class::getNonTimestampPks() as $key) {
             $query->where($key, '!=', $obj->{$key});
         }
     }
     // do we have records with this slug?
     $same = $query->get();
     // make sure our slug is unique
     if (!empty($same)) {
         $max = -1;
         foreach ($same as $record) {
             if (preg_match('/^' . $slug . '(?:-([0-9]+))?$/', $record->{$this->_property}, $matches)) {
                 $index = isset($matches[1]) ? (int) $matches[1] : 0;
                 $max < $index and $max = $index;
             }
         }
         $max < 0 or $slug .= '-' . ($max + 1);
     }
     $obj->{$this->_property} = $slug;
 }
コード例 #19
0
ファイル: LoginAction.class.php プロジェクト: redisck/xiangmu
 public function dologin()
 {
     $admin = M("Admin");
     $pwd = md5($_POST['admin_pwd']);
     $info = $admin->where(array('admin_name' => "{$_POST['admin_name']}", 'admin_pwd' => "{$pwd}"))->select();
     if (!$info) {
         echo "<meta charset='utf-8'>";
         echo "<script>alert('用户名或者密码错误')</script>";
         $this->redirect('Login/index');
     }
     if (md5($_POST['verifycode']) != $_SESSION['verify']) {
         echo "<meta charset=utf-8>";
         echo "<script>alert('验证码错误')</script>";
         $this->redirect('Login/index');
     }
     $data['last_login_time'] = time();
     $data['last_login_ip'] = ip2long("{$_SERVER['REMOTE_ADDR']}");
     $admin->where(array('admin_name' => "{$_POST['admin_name']}"))->save($data);
     $_SESSION['admin']['name'] = $_POST['admin_name'];
     $_SESSION['admin']['id'] = $info[0]['id'];
     //写入权限
     $role_node = new Model();
     $nodes = $role_node->query("select rn.node_id from qd_role_node as rn,qd_admin_role as ar where ar.role_id=rn.role_id and ar.admin_id=" . $_SESSION['admin']['id']);
     foreach ($nodes as $key => $value) {
         $arr[] = $value['node_id'];
     }
     $_SESSION['admin']['nodes'] = $arr;
     $this->redirect('Index/index');
 }
コード例 #20
0
ファイル: translate.php プロジェクト: roae/hello-world
 /**
  * 	TranslateBehavior::afterSave
  * 	callback
  *
  * 	@param Model $Model modelo que actua como este Behavior.
  * 	@param Boolean $created indica si hizo insert o update.
  * 	@return void
  * 	@access public
  */
 function afterSave(&$Model, $created)
 {
     #$dbo = $Model->getDatasource();
     #$this->log(current(end($dbo->_queriesLog)),"Translate");
     //$this->log($this->settings,"Translate");
     if (isset($this->settings[$Model->alias])) {
         $idiomas = Configure::read("I18n.Langs");
         $locale = Configure::read("I18n.Locale");
         //Clave del idioma
         $data = array();
         $tableName = $this->I18n->tablePrefix . $this->I18n->table;
         $query = "REPLACE INTO {$tableName} (locale,model,foreign_key,field,content) values ";
         $tradujo = false;
         App::import('Core', 'Sanitize');
         foreach ($this->settings[$Model->alias] as $field) {
             if (isset($Model->data[$Model->alias][$field . '_' . $locale]) || isset($Model->data[$Model->alias][$field])) {
                 $content = isset($Model->data[$Model->alias][$field]) ? $Model->data[$Model->alias][$field] : $Model->data[$Model->alias][$field . '_' . $locale];
                 $query .= "('" . $locale . "','" . $Model->name . "'," . $Model->id . ",'" . $field . "','" . Sanitize::escape($content) . "'),";
                 foreach ($idiomas as $_locale => $idioma) {
                     if (isset($Model->data[$Model->alias][$field . '_' . $_locale])) {
                         $query .= "('" . $_locale . "','" . $Model->name . "'," . $Model->id . ",'" . $field . "','" . Sanitize::escape($Model->data[$Model->alias][$field . '_' . $_locale]) . "'),";
                     }
                 }
                 $tradujo = true;
             }
         }
         if ($tradujo) {
             $query = substr($query, 0, -1);
             $this->I18n->query($query);
         }
     }
     #$this->log(current(end($dbo->_queriesLog)),"Translate");
 }
コード例 #21
0
ファイル: entries_controller.php プロジェクト: summea/mi
 public function edit()
 {
     #$id = $this->getPrimaryKey();
     $id = 10;
     $entries = Model::query("select * from mi_entries where id = {$id}");
     $this->set('primary_key', $id);
     $this->set('entries', $entries);
 }
コード例 #22
0
 public function index()
 {
     $Model = new Model();
     // 实例化一个model对象 没有对应任何数据表
     $articles = $Model->query("select a.id, a.title,a.sorts, a.click,a.updatetime,c.`name` as c_name, c.linktype as cls_type, a.linktype  linktype, a.link_param_l1  link_param_l1, a.link_param_l2  link_param_l2 , a.token token " . "from tp_article as a left JOIN tp_classify as c on a.c_id = c.id and (c.`status` =1 or c.`status` =0) " . "where a.status = 1  and a.token='{$this->token}'");
     $this->assign('articles', $this->generateLinkTypeDesc($articles));
     $this->display();
 }
コード例 #23
0
 public function add()
 {
     $tmplId = $this->_post('optype', 'intval');
     $allTmpls = C('web_homepage_tmpl');
     if (isset($allTmpls[$tmplId])) {
         if ($allTmpls[$tmplId]['free'] == 0) {
             //检查是否已购买相应的功能
             $cur = time();
             $uid = session('uid');
             $sql = 'select * from tp_users as u left JOIN tp_user_func_group as g on u.id = g.user_id' . " where u.id = {$uid} and g.group_id=14 and g.expire_time > {$cur} and g.start_time < {$cur}";
             $Model = new Model();
             // 实例化一个model对象 没有对应任何数据表
             $opened_func = $Model->query($sql);
             if ($opened_func == false) {
                 $this->ajaxReturn("请联系客服购买“微网站模板充值码”", "Failed", 4);
             }
         } else {
             if (isset($allTmpls[$tmplId]['exlusive']) && !in_array($this->token, $allTmpls[$tmplId]['exlusive'] || $allTmpls[$tmplId]['enabled'] != 1)) {
                 $this->ajaxReturn("该模板不可用", "Failed", 5);
             }
         }
         $data['tmpl_id'] = $allTmpls[$tmplId]['id'];
         $data['tmpl_name'] = $allTmpls[$tmplId]['view'];
         $data['show_nav'] = $this->_post('show_nav');
         $data['update_time'] = time();
         /*if (isset($allTmpls[$tmplId]['support_diy_bg_pic']) 
               && $allTmpls[$tmplId]['support_diy_bg_pic'] == 1) 
           { 
               $data['bg_pic_url'] = $this->_post('bg_pic_url','trim');
           }*/
         if (isset($allTmpls[$tmplId]['support_diy_bg_color']) && $allTmpls[$tmplId]['support_diy_bg_color'] == 1) {
             $data['bg_color'] = $this->_post('bg_color', 'trim');
         }
         if (isset($allTmpls[$tmplId]['support_diy_classify_color']) && $allTmpls[$tmplId]['support_diy_classify_color'] == 1) {
             $data['classify_bg_color'] = $this->_post('classify_bg_color', 'trim');
             $data['classify_font_color'] = $this->_post('classify_font_color', 'trim');
         }
         $data['navi_bg_color'] = $this->_post('navi_bg_color', 'trim');
         if ($_SESSION['token'] != 'lingzhtech' && $data['tmpl_name'] == 'index_lingzhtech') {
             exit;
         }
         $db = M('vweb_setting');
         $where['token'] = $this->token;
         $tmpl = $db->where($where)->find();
         $ret = 0;
         if ($tmpl != false) {
             $ret = $db->where($where)->save($data);
         } else {
             $data['token'] = $this->token;
             $ret = $db->add($data);
         }
         if ($ret) {
             $this->ajaxReturn("更新成功", "OK", 1);
         } else {
             $this->ajaxReturn("更新失败", "ERROR", 0);
         }
     }
 }
コード例 #24
0
 public function _initialize()
 {
     parent::_initialize();
     $agent = $_SERVER['HTTP_USER_AGENT'];
     /* xxl just for test 		
     		if(!strpos($agent,"icroMessenger")&&!isset($_GET['show'])) {
     			echo '此功能只能在微信浏览器中使用';exit;
     		}
     */
     //
     $Model = new Model();
     $rt = $Model->query("CREATE TABLE IF NOT EXISTS `tp_site_plugmenu` (\r\n  `token` varchar(60) NOT NULL DEFAULT '',\r\n  `name` varchar(20) NOT NULL DEFAULT '',\r\n  `url` varchar(100) DEFAULT '',\r\n  `taxis` mediumint(4) NOT NULL DEFAULT '0',\r\n  `display` tinyint(1) NOT NULL DEFAULT '0',\r\n  KEY `token` (`token`,`taxis`,`display`)\r\n) ENGINE=MyISAM DEFAULT CHARSET=utf8");
     //
     $this->token = $this->_get('token', 'trim');
     if (!isset($_SESSION['token'])) {
         $_SESSION['token'] = $this->token;
     }
     //$where['token']=$this->token;
     $tpl = D('Wxuser')->where($where)->find();
     $this->weixinUser = $tpl;
     if (isset($_GET['wecha_id']) && $_GET['wecha_id']) {
         $_SESSION['wecha_id'] = $_GET['wecha_id'];
         $this->wecha_id = $this->_get('wecha_id');
     }
     if (isset($_SESSION['wecha_id'])) {
         $this->wecha_id = $_SESSION['wecha_id'];
     }
     //dump($where);
     //$info=M('Classify')->where(array('token'=>$this->_get('token'),'status'=>1))->order('id asc')->select();
     $info = M('function_master')->where(array('class' => 1))->order('orderno asc')->select();
     $info = $this->convertLinks($info);
     //加外链等信息
     $gid = D('Users')->field('gid')->find($tpl['uid']);
     $this->userGroup = M('User_group')->where(array('id' => $gid['gid']))->find();
     $this->copyright = $this->userGroup['iscopyright'];
     $this->info = $info;
     $tpl['color_id'] = intval($tpl['color_id']);
     $this->tpl = $tpl;
     $company_db = M('company');
     $this->company = $company_db->where(array('token' => $this->token, 'isbranch' => 0))->find();
     $this->assign('company', $this->company);
     //
     $homeInfo = M('home')->where(array('token' => $this->token))->find();
     $this->homeInfo = $homeInfo;
     $this->assign('iscopyright', $this->copyright);
     //是否允许自定义版权
     $this->assign('siteCopyright', C('copyright'));
     //站点版权信息
     $this->assign('homeInfo', $homeInfo);
     //
     $this->assign('token', $this->token);
     //
     $this->assign('copyright', $this->copyright);
     //plugmenus
     $plugMenus = $this->_getPlugMenu();
     $this->assign('plugmenus', $plugMenus);
     $this->assign('showPlugMenu', count($plugMenus));
 }
コード例 #25
0
ファイル: TestAction.class.php プロジェクト: belerweb/pigcms
 public function index()
 {
     $mod = new Model();
     $sql = "SELECT COUNT( mer_id ) AS count, mer_id FROM  `pigcms_merchant_user_relation` GROUP BY mer_id";
     $res = $mod->query($sql);
     foreach ($res as $r) {
         D('Merchant')->where(array('mer_id' => $r['mer_id']))->save(array('fans_count' => $r['count']));
     }
 }
コード例 #26
0
ファイル: eventsModel.class.php プロジェクト: ndusan/belvi
	public function getCarouselImagesEvent($params){
		if(isset($params['id']) && !empty($params['id']))
			$query = sprintf("SELECT * FROM `events` WHERE `id`!='%s'",
							mysql_real_escape_string($params['id'])
							);
		else 
			$query = sprintf("SELECT * FROM `events` WHERE `main`='0'");
		return parent::query($query);
	}
コード例 #27
0
 public function postList()
 {
     $model = new Model();
     //thinkphp做连接查询把post_parent换成文本而不是数字 ps:连接查询还是用原生sql 速度要快一些 用法很简单new 一个空的model就可以
     $sql = 'select blog_category.cat_name,blog_content.* from blog_content join blog_category on blog_category.cat_id = blog_content.post_parent';
     $posts = $model->query($sql);
     $this->assign('posts', $posts);
     $this->display();
 }
コード例 #28
0
 public function getName($id)
 {
     //$array=array("ID"=>$id);
     if ($id == 0 or $id == "0") {
         return "无";
     }
     $result = parent::query(array("ID" => $id), array("name"));
     return $result[0]["name"];
 }
コード例 #29
0
    public function _needUpdate()
    {
        $Model = new Model();
        $Model->query(('CREATE TABLE IF NOT EXISTS `' . C('DB_PREFIX')) . 'system_info` (`lastsqlupdate` INT( 10 ) NOT NULL ,`version` VARCHAR( 10 ) NOT NULL) ENGINE = MYISAM CHARACTER SET utf8');
        $Model->query(('CREATE TABLE IF NOT EXISTS `' . C('DB_PREFIX')) . 'update_record` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `msg` varchar(600) NOT NULL DEFAULT \'\',
  `type` varchar(20) NOT NULL DEFAULT \'\',
  `time` int(10) NOT NULL DEFAULT \'0\',
  PRIMARY KEY (`id`)
) ENGINE=MYISAM DEFAULT CHARSET=utf8');
        $updateRecord = M('System_info')->order('lastsqlupdate DESC')->find();
        $key = $this->key;
        $url = ((((($this->server_url . '?act=server&key=') . $key) . '&lastversion=') . $updateRecord['version']) . '&domain=') . $this->topdomain;
        $remoteStr = @Saivi_getcontents($url);
        $rt = json_decode($remoteStr, 1);
        return $rt;
    }
コード例 #30
0
ファイル: Blog.php プロジェクト: M4R1KU/WebLog
 /**
  * inserts a new row into the table with the instancevariables
  * and sets the id for the current object
  *
  * @return bool
  */
 public function create()
 {
     $query = "INSERT INTO Blog (name, id_user) VALUES ('" . $this->name . "', '" . $this->user->getId() . "')";
     $res = parent::query($query);
     if ($res) {
         $this->id = parent::getLastId();
         return true;
     }
 }