예제 #1
0
 static function select_c($columns, $where = null, $page = null, $pagesize = null, $order = null)
 {
     if ($columns) {
         //如果有column的话加个id和kind,以后用columns不加id和kind
         if ("id" == $columns) {
             $columns = self::$data_id;
         } else {
             $columns = self::$data_id . "," . self::$data_columns[kind] . "," . $columns;
         }
     }
     if (!$order) {
         $order = self::$data_id . " desc";
     }
     if (!$page) {
         $page = 0;
     }
     $limit_begin = $page * $pagesize;
     $limit_num = $pagesize;
     $limit = $limit_begin . "," . $limit_num;
     if (!$no_u) {
         sql_use::update_nowtime(self::$data_table, self::$data_columns[time], $where);
         //找一次更新一次时间
     }
     $result = sql_use::select(self::$data_table, $columns, $where, $order, $limit, false);
     //注意最后一个变量为true则显示sql语句
     return $result;
 }
예제 #2
0
 static function show_res(config $config)
 {
     $rs = sql_use::select($config->d_table, $config->d_id . "," . $config->d_columns[content], $config->d_columns[kind] . " = 11");
     foreach ($rs as $r) {
         if (empty($result)) {
             $result = NULL;
         }
         $result = $result . $r[$config->d_columns[content]] . "(" . $r[$config->d_id] . ")\n订餐热线:" . sql_use::select_one($config->d_table, $config->d_columns[content], $config->d_columns[kind] . " = 13 and " . $config->d_columns[upid] . "=" . $r[$config->d_id]) . "\n\n";
     }
     return $result;
 }
예제 #3
0
 static function select($columns = null, $where = null, $kind = null, $order = null, $limit = null, $show = false)
 {
     if ($kind) {
         //类别是数组的情况
         if (is_array($kind)) {
             foreach ($kind as $k) {
                 if (!is_numeric($kind)) {
                     $k = "'" . $k . "'";
                 }
                 $kind_where = $kind_where . " or " . self::$data_columns[kind] . "=" . $k;
             }
             $kind_where = substr($kind_where, 3);
         } else {
             if (!is_numeric($kind)) {
                 $kind = "'" . $kind . "'";
             }
             $kind_where = self::$data_columns[kind] . "=" . $kind;
         }
         //有where的情况
         if ($where) {
             if ($where[0] == "(") {
                 $no_u = 1;
             }
             $where = $where . " and (" . $kind_where . ")";
         } else {
             $where = $kind_where;
         }
     }
     if ($columns) {
         //如果有column的话加个id和kind,以后用columns不加id和kind
         if ("id" == $columns) {
             $columns = self::$data_id;
         } else {
             $columns = self::$data_id . "," . self::$data_columns[kind] . "," . $columns;
         }
     }
     if (!$order) {
         $order = self::$data_id . " desc";
     }
     if (!$no_u) {
         sql_use::update_nowtime(self::$data_table, self::$data_columns[time], $where);
         //找一次更新一次时间
     }
     $result = sql_use::select(self::$data_table, $columns, $where, $order, $limit, $show);
     //这里就是将数据收藏到收藏表中
     //            self::collect_result($result, 11);//最后那个11意思是查看
     return $result;
 }