/** * 需要优化的商品列表 * @param array $where 条件 * @param string $column 要显示的字段 * @param integer $offset 分页 * @param integer $limit 分页 * @param string $order 排序 */ public function starList($where = array(), $column = "*", $offset = 0, $limit = 20, $order = 'pid 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)) { 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'])) { $condition .= ' and state = 1'; } $goods = Pdoptimize::find(array($condition, 'bind' => $bind, 'columns' => $column, 'order' => $order, 'offset' => $offset, 'limit' => $limit)); $count = Pdoptimize::count(array($condition, "bind" => $bind)); if ($goods) { $goods = $goods->toArray(); $goods['count'] = $count; return $this->outputData($goods); } else { return $this->outputData(); } }