Example #1
0
 public function getCategoryAll()
 {
     $model = new Model();
     $query = 'SELECT * FROM category';
     $values = $model->select($query);
     return $values;
 }
Example #2
0
 public function active_info()
 {
     $v_id = $this->get_volun_id();
     $obj = new Model('t_active');
     if (empty($v_id)) {
         $other_content = $obj->select();
         $this->assign('other_content', $other_content);
     } else {
         //列出自己发布的项目
         $where = 'v_id=\'' . $v_id . '\'';
         $my_content = $obj->where($where)->select();
         $this->assign('my_content', $my_content);
         $v_g = new Model('t_volun_group');
         $act = $v_g->where('volun_join_id=\'' . $v_id . '\'')->field('a_id')->select();
         $arr = array();
         foreach ($act as $v) {
             $arr[] = $v['a_id'];
         }
         $str2 = implode(',', $arr);
         //我参与的活动
         $where = 'a_id in (' . $str2 . ')';
         $my_join_content = $obj->where($where)->select();
         $this->assign('my_join_content', $my_join_content);
         //列出不是自己发布的项目
         $where = 'v_id<>\'' . $v_id . '\'';
         $other_content = $obj->where($where)->select();
         $this->assign('other_content', $other_content);
     }
     $this->display();
 }
Example #3
0
 public function add()
 {
     $where['id'] = $_GET['id'];
     if ($where['id']) {
         $array = $this->SelfDB->where($where)->find();
         /*
         			if (C('web_admin_edittime')){
         			$array['checktime']= 'checked';
         			}
         */
         $array['tpltitle'] = '编辑';
     } else {
         $array['addtime'] = time();
         //$array['checktime']= 'checked';
         $array['tpltitle'] = '添加';
     }
     $this->assign('array', $array);
     //手工分类
     //$m	=	new module('self_type');
     $m = new Model('self_type');
     //var_dump($m);
     $select = $m->select();
     $dataArr = $this->SelfDB->order('orders desc')->select();
     //print_r($select);
     $this->assign('typeArr', $select);
     $this->assign('dataArr', $dataArr);
     $this->display('./views/admin/Self_index.html');
 }
Example #4
0
 public function index()
 {
     $db = new Model('user');
     $select = $db->select();
     $this->assign('select', $select);
     $this->display();
 }
 public function findOne()
 {
     $where = array("id='{$this->R['id']}'");
     if (!$this->check->checkOne($this, $where)) {
         $this->check->showError();
     }
     return parent::select(array('id', 'price_left', 'price_right'), array('where' => $where, 'limit' => '1'));
 }
Example #6
0
 public function findAllNav()
 {
     $_allPrice = parent::select(array('id', 'price_left', 'price_right'), array('order' => 'price_left ASC,price_right ASC'));
     foreach ($_allPrice as $_value) {
         $_value->value = $_value->price_left . ' - ' . $_value->price_right;
     }
     return $_allPrice;
 }
Example #7
0
 public function findOne()
 {
     $_where = array("id='{$this->_R['id']}'");
     if (!$this->_check->oneCheck($this, $_where)) {
         $this->_check->error();
     }
     return parent::select(array('id', 'name', 'url', 'info', 'price_in', 'price_out', 'price_add'), array('where' => $_where, 'limit' => '1'));
 }
Example #8
0
 public function ajaxTest()
 {
     $Demo = new Model('Demo');
     // 实例化模型类
     $list = $Demo->select();
     // 查询数据
     $this->ajaxReturn($list, "新增错误!", 1);
 }
Example #9
0
 /**
  * constructs new object from database with the the id $id
  *
  * @param $id
  * @return Blog
  */
 public static function constructBlogByID($id)
 {
     $query = "SELECT * FROM Blog WHERE blog_id = " . intval($id);
     $res = parent::select($query);
     if ($res) {
         return self::constructBlog($res[0]);
     }
 }
 public function findOne()
 {
     $where = array("id='{$this->R['id']}'");
     if (!$this->check->checkOne($this, $where)) {
         $this->check->showError();
     }
     return parent::select(array('id', 'name', 'url', 'info', 'type'), array('where' => $where, 'limit' => '1'));
 }
Example #11
0
 public function findOne()
 {
     $_where = array("user='******'user']}' AND selected = 1");
     //        if(!$this->_check->oneCheck($this,$_where))
     //        {
     //            $this->_check->error();
     //        }
     return parent::select(array('id', 'user', 'name', 'email', 'tel', 'code', 'buildings', 'address', 'flag'), array('where' => $_where, 'limit' => '1'));
 }
Example #12
0
 public function findOne()
 {
     $_where = array("goods_id='{$this->_R['goods_id']}' AND order_id='{$this->_R['order_id']}'");
     //		if(!$this->_check->oneCheck($this,$_where))
     //		{
     //			$this->_check->error();
     //		}
     return parent::select(array('star', 'content', 're_content'), array('where' => $_where, 'limit' => '1'));
 }
Example #13
0
 public function index()
 {
     $m = new Model('User');
     $arr = $m->select();
     //print_r($arr);
     $this->assign('data', $arr);
     //这样可以在view页面动态的输出$data
     $this->display();
 }
 public function findOne()
 {
     $where = array("user='******'user']}'", "selected=1");
     if (isset($this->R['id'])) {
         $where = array("id='{$this->R['id']}'");
     }
     //if(!$this->check->checkOne($this,$where))$this->check->showError();
     return parent::select(array('id', 'name', 'email', 'address', 'flag', 'tel', 'time', 'code', 'buildings'), array('where' => $where, 'limit' => '1'));
 }
Example #15
0
 public function delete()
 {
     $_where = array("id='{$this->_R['id']}'");
     $_service = parent::select(array('first'), array('where' => $_where, 'limit' => '1'));
     if ($_service[0]->first == 1) {
         return 0;
     } else {
         return parent::delete($_where);
     }
 }
 public function delete()
 {
     $where = array("id='{$this->R['id']}'");
     $service = parent::select(array('id', 'first'), array('limit' => 1, 'where' => $where));
     if ($service[0]->first == 1) {
         return false;
     } else {
         return parent::delete($where);
     }
 }
Example #17
0
 public function index()
 {
     $db = new Model('user');
     // 实例化模型类,参数数据表名称,不包含前缀
     $select = $db->select();
     // 查询数据
     $this->assign('select', $select);
     // 模板变量赋值
     $this->display();
     // 输出模板
 }
Example #18
0
 /**
  * @static
  * @param $id
  * @return array|bool
  * Function get all the data about one post if you know the post's id
  */
 public static function getOne($id)
 {
     //construct your SQL query-- select all the data about one post by id
     $sql = 'SELECT * FROM posts WHERE id = ' . $id . ' LIMIT 1';
     //send that query to the Model class that Posts extends
     $results = Model::select($sql);
     //return results to controller
     if ($results) {
         return $results[0];
     } else {
         return false;
     }
 }
Example #19
0
 /**
  * gets all rows of the table
  * @return array
  */
 public function getAll()
 {
     $query = "SELECT * FROM Category";
     $res = parent::select($query);
     if ($res) {
         $out = array();
         foreach ($res as $row) {
             $b = self::constructCatByID($row['category_id']);
             $out[] = $b;
         }
         return $out;
     }
 }
 public function getAllCollect()
 {
     $result = parent::select(array('goods_id', 'user'), array('where' => array("user='******'user']}'"), 'order' => 'date DESC'));
     $id = '';
     foreach ($result as $key => $value) {
         $id .= $value->goods_id . ',';
     }
     $id = substr($id, 0, -1) ? substr($id, 0, -1) : 0;
     $this->tables = array(DB_FREFIX . 'goods g');
     $allGoods = parent::select(array('id', 'name', 'thumb', 'price_sale', 'price_market', 'unit', 'sale_count', 'thumb_small', 'nav', '(SELECT COUNT(*) FROM mall_commend c WHERE c.goods_id=g.id) AS count'), array('where' => array("id IN ({$id})", 'is_up=1'), 'limit' => $this->limit));
     $this->tables = array(DB_FREFIX . 'collect');
     return $allGoods;
 }
Example #21
0
 public function getByCategoryID($id, $page)
 {
     $model = new Model();
     $query = 'SELECT * FROM lot l
             JOIN category c
             ON l.category_id=c.id
             JOIN `user` u
             ON u.id=l.user_id
             WHERE is_active=1 AND l.category_id=' . $id . '
             ORDER BY l.`created` DESC
             LIMIT 6 OFFSET ' . ($page - 1) * 6;
     $values = $model->select($query);
     return $values;
 }
Example #22
0
 /**
  * gets all entries by the blog wich is given
  *
  * @param mixed $blog
  * @return array all entries
  */
 public function getByBlog($blog)
 {
     $id = $blog instanceof Blog ? $blog->getId() : $blog;
     $query = "SELECT * FROM Entry WHERE id_blog = " . intval($id) . " ORDER BY date DESC";
     $res = parent::select($query);
     if ($res) {
         $out = array();
         foreach ($res as $row) {
             $e = self::constructEntry($row);
             $out[] = $e;
         }
         return $out;
     }
 }
Example #23
0
 /**
  * gets all comments by the entry wich is given
  *
  * @param mixed $entry
  * @return array all comment
  */
 public static function getByEntry($entry)
 {
     $id = $entry instanceof Entry ? $entry->getId() : $entry;
     $query = "SELECT * FROM Comment WHERE id_entry = " . intval($id);
     $res = parent::select($query);
     if ($res) {
         $out = array();
         foreach ($res as $row) {
             $e = self::constructCom($row);
             $out[] = $e;
         }
         return $out;
     }
 }
Example #24
0
 public function login()
 {
     $db = new Model();
     $db->_tabela = $this->tableName;
     $where = $this->userColumn .= "='" . $this->user . "' AND " . $this->passColumn . "='" . $this->pass . "'";
     $sql = $db->select($where, '1');
     if (count($sql) > 0) {
         $this->sessionHelper->createSession("userAuth", true)->createSession("userData", $sql[0]);
     } else {
         die("Usuário inexistente!");
     }
     $this->redirectorHelper->goToControllerAction($this->loginController, $this->logoutAction);
     return $this;
 }
 function selectModel(Model $model)
 {
     $foreignKey = $this->foreignKey;
     if (isset($model->{$foreignKey})) {
         $select = $this->augmentSelect($model->all());
         $select = $select->equal(Model::tableFor($this->localClass) . '.' . $this->foreignKey, $model->{$foreignKey});
     } else {
         $select = $this->augmentSelect($model->select());
     }
     if (isset($select[0])) {
         return $select[0];
     } else {
         return null;
     }
 }
Example #26
0
 public function getIndex()
 {
     $model = new Model();
     $query = 'SELECT l.*,c.name,u.first_name,u.last_name,u.email,u.phone
             FROM lot l
             JOIN category c
             ON l.category_id=c.id
             JOIN `user` u
             ON u.id=l.user_id
             WHERE is_active=1
             ORDER BY l.`created` DESC
             LIMIT 8';
     $result['lastGoods'] = $model->select($query);
     return $result;
 }
Example #27
0
 /**
  * 添加/修改页面
  */
 public function detail()
 {
     // 限制表单上传的最大值
     $this->MAX_FILE_SIZE = 1024000;
     $cmo = new Model('category');
     $cidList = $cmo->select();
     $this->cidList = Arr::simple($cidList);
     if (empty($_GET['id']) || !ctype_digit($_GET['id'])) {
         $detail = array();
     } else {
         $id = $_GET['id'];
         $mo = new Model_Article();
         $detail = $mo->read($id);
     }
     if ($detail) {
         $detail['post_time'] = date('Y-m-d H:i:s', $detail['post_time']);
         $this->detail = $detail;
     } else {
         $this->detail = array('status' => 1, 'views' => rand(1, 99), 'post_time' => date('Y-m-d H:i:s'));
     }
 }
Example #28
0
 public function select($data = array())
 {
     $from = '';
     foreach ($this->view as $table => $set) {
         if (!empty($this->joinTable) && !in_array($table, $this->joinTable)) {
             continue;
         }
         $from .= C('DB_PREFIX') . $table . ' ' . $table;
         //字段
         foreach ($set as $name => $f) {
             if ($name !== '_type' && $name !== '_on') {
                 $field = is_string($name) ? array($table . '.' . $name => $f) : $f;
                 $this->field($field);
             }
         }
         if (isset($set['_on'])) {
             $on = preg_replace('@__(\\w+)__@', '\\1', $set['_on']);
             $from .= " ON {$on} ";
         }
         //_TYPE关联方式
         if (isset($set['_type'])) {
             $from .= ' ' . strtoupper($set['_type']) . ' JOIN ';
         }
     }
     if (substr($from, -11) == 'INNER JOIN ') {
         $from = substr($from, 0, -11);
     }
     if (substr($from, -11) == 'RIGHT JOIN ') {
         $from = substr($from, 0, -11);
     }
     if (substr($from, -10) == 'LEFT JOIN ') {
         $from = substr($from, 0, -10);
     }
     $this->db->opt['table'] = $from;
     $this->joinTable = array();
     return parent::select($data);
 }
 public function select($fields)
 {
     return parent::select($fields);
 }
Example #30
0
 public function access()
 {
     $id = I('id');
     $m = new Model('admin_role');
     $res = $m->where('id=' . $id)->find();
     $this->assign('role_info', $res);
     $m = new Model('admin_node');
     $res = $m->select();
     //$this->AAA($res);
     $res2 = $this->getNodeTree($res);
     //$this->AAA($res2);
     $m = new Model('admin_access');
     foreach ($res as $key => $val) {
         if ($m->where('role_id=' . $id . ' AND node_id=' . $val['id'])->count()) {
             $res[$key]['access'] = 1;
         } else {
             $res[$key]['access'] = 0;
         }
     }
     $this->assign('node_info', $res);
     $this->assign('id', $id);
     $this->display();
 }