# thinkjava **Repository Path**: meanshare/thinkjava ## Basic Information - **Project Name**: thinkjava - **Description**: 一个轻量级的数据库操作框架,更方便的操作数据库。不需要配置文件。傻瓜式操作。有java基础即可用。不需要学习其他东西。 于鄙人学了两天TP5框架,由于长时间写PHP,忘掉了很多spring mvc ,mybatis 等一些列框架。所以现在决定,抄袭TP5的一切思维逻辑。搬到我们的JAVA上面来。希望喜欢的朋友帮忙点个赞。 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: http://www.chanmir.com - **GVP Project**: No ## Statistics - **Stars**: 7 - **Forks**: 0 - **Created**: 2017-12-01 - **Last Updated**: 2025-05-15 ## Categories & Tags **Categories**: database-dev **Tags**: None ## README 使用的地方就是这样使用 - 数据库的增删改查操作,多个方法重载 - 分页 - 包含了各种常用操作库 ### 插入数据实例 ``` public void insert() { User accounts = new User(); Map item1 = new HashMap();//插入一条 accounts.insert(item1); ArrayList> list = new ArrayList>(); for (int i = 0; i < 10000; i++) { Map item = new HashMap(); item.put("username", "admin"); item.put("password", "123456"); list.add(item); } accounts.insert(list); } ``` ### 更新实例 ``` public void update() { User accounts = new User(); Map data = new HashMap();//更新数据 data.put("username", "admin123"); Map where = new HashMap();//查询条件 where.put("userid", "1"); boolean flag= accounts.update(data, where);//成功则返回true if(flag){ //更新成功后的业务逻辑 }else{ //更新失败后的业务逻辑 } } ``` 查询实例 ``` public void select() { User accounts = new User(); ArrayList data = new ArrayList();//你要查询的列的名字,为空则为所有 data.add("username"); data.add("password"); Map where = new HashMap();//查询条件 where.put("state", "1"); ArrayList> datalist1=accounts.select(data, where);//查询所有 ArrayList> datalist2=accounts.select(data, where,1,1);//查询所有并分页第一个值为页码第二个为页大小 ArrayList> datalist3=accounts.select(data, where,"userid desc,username desc");//查询排序 ArrayList> datalist4=accounts.select(data, where,1,1,"userid desc,username desc");//查询分页并排序 Map item=accounts.selectone(data, where);//查询一条数据 for (Map map : datalist1) {//遍历出来 String username=map.get("username"); String password=map.get("password"); System.out.println("用户名为:"+username+"密码为:"+password+"\r\n"); } } ``` ### 删除实例 ``` public void delete() { User accounts = new User(); Map where = new HashMap();//查询条件 where.put("userid", "1"); boolean flag= accounts.delete(where);//成功则返回true if(flag){ //删除成功后的业务逻辑 }else{ //删除失败后的业务逻辑 } } ``` ### 模型类实例 ``` public class User extends BaseModel { /** *若类名与表名一致则无需加入本行,若不一致,则需要加入以下代码 public User() { super("accounts"); } */ } ```