"", "secret" => "", "app_name" => "", "status" => "", "create_time" => "" ); public function get_model(){ return $this->model; } public function get_appauth_with_id($id) { return $this->mongo_db->where(array("app_id" => $id))->find_one($this->collection_name); } public function is_exists($field, $val, $old_val=null) { if ($old_val) { $appauth = $this->mongo_db->set_wheres(array('$and' => array(array($field => array('$ne' => $old_val)), array($field => $val))))->get($this->collection_name); } else { $appauth = $this->mongo_db->where(array($field => $val))->get($this->collection_name); } if ($appauth && count($appauth) > 0) { return true; } else { return false; } } /** * 列表应用授权 */ public function list_appauth($limit, $offset, $like = NULL, $where = NULL, $order = NULL) { if (!$order) { $order = array("create_time" => "ASC"); } if ($like && $where) { return $this->mongo_db->like("app_name", $like)->where($where)->order_by($order)->limit($limit)->offset($offset)->get($this->collection_name); } else if ($like && !$where) { return $this->mongo_db->like("app_name", $like)->order_by($order)->limit($limit)->offset($offset)->get($this->collection_name); } else if (!$like && $where) { return $this->mongo_db->where($where)->order_by($order)->limit($limit)->offset($offset)->get($this->collection_name); } else { return $this->mongo_db->order_by($order)->limit($limit)->offset($offset)->get($this->collection_name); } } /** * 获取应用授权数据条数 */ public function count_appauth($like = NULL, $where = NULL) { if ($like && $where) { return $this->mongo_db->like("app_name", $like)->where($where)->count($this->collection_name); } else if ($like && !$where) { return $this->mongo_db->like("app_name", $like)->count($this->collection_name); } else if (!$like && $where) { return $this->mongo_db->where($where)->count($this->collection_name); } else { return $this->mongo_db->count($this->collection_name); } } /** *新增应用授权 */ public function insert_appauth($app_auth) { return $this->mongo_db->insert($this->collection_name, $app_auth); } public function set_val($field, $wheres, $value = NULL) { if (is_array($field)) { return $this->mongo_db->set_wheres($wheres)->set($field)->update_all($this->collection_name); } else { return $this->mongo_db->set_wheres($wheres)->set($field, $value)->update_all($this->collection_name); } } /** *更新应用授权 */ public function update_appauth($app_auth) { $data['filter'] = array("app_id" => $app_auth['app_id']); $data['update'] = $app_auth; return $this->mongo_db->update($this->collection_name, $data); } /** * 删除应用授权 */ public function delete_appauth($app_id) { return $this->mongo_db->where(array("app_id" => $app_id))->delete($this->collection_name); } }