/** * 获取普通产品列表 * @param array $where 条件 * @param string $column 字段 * @param integer $offset 分页 * @param integer $limit 分页 * @param integer $type 1为正式表 2为m表 * @param string $order 排序 */ public function commonList($where = array(), $column = "*", $offset = 0, $limit = 20, $type = 1, $order = 'uptime DESC') { $condition = '1'; $bind = array(); $offset = $this->di['filter']->sanitize($offset, 'int', 0); $limit = $this->di['filter']->sanitize($limit, 'int', 20); if (is_array($where)) { if (!array_key_exists('cid', $where)) { return $this->outputData(false, 600, '暂无数据'); } foreach ($where as $key => $value) { if (is_array($value)) { $value = $this->di['filter']->sanitize($value, "string", ''); $condition .= ' and ' . $key . ' in(' . implode(',', $value) . ')'; } else { $value = $this->di['filter']->sanitize($value, "string", 0); $condition .= ' and ' . $key . '=:' . $key . ':'; $bind[$key] = $value; } } } if (!isset($where['state'])) { if ($type == 1) { $condition .= ' and state in (0,1,-1,-2)'; } else { $condition .= ' and state = -1'; } } $goods = array(); if ($type == 1) { $goods = \Gcproinfo\Models\Pdinfo::find(array($condition, "bind" => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit))->toArray(); $count = \Gcproinfo\Models\Pdinfo::count(array($condition, "bind" => $bind)); } else { $goods = \Gcproinfo\Models\Mproduct::find(array($condition, "bind" => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit))->toArray(); $count = \Gcproinfo\Models\Mproduct::count(array($condition, "bind" => $bind)); } $goods['count'] = $count; return $this->outputData($goods); }