Weed3 一个微型ORM框架(只有0.1Mb哦)
源码:https://github.com/noear/weed3
源码:https://gitee.com/noear/weed3
一、table() 执行:链式ORM操作
此处略(前面主要就讲这个接口)
二、call(..) 执行:存储过程 或 查询过程
//执行存储过程
db.call("user_get").set("_user_id",1).getMap();
//执行查询过程(我暂时这么叫它)
db.call("select * from user where id=@user_id").set("@user_id",1).getMap();
三、sql(..) 执行:SQL语句
db.sql("select * from user where id=?",1).getMap();
db.sql(..) 还有一个快捷版:db.exec(..)。相当于:db.sql(...).execute(); //批处理时,可快速写增、删、改动作
例:db.exec("DELETE FROM test where a=1")
最终统一返回:IQuery (保证了体验的统一性)
db.table(..).select(..) -> IQuery
db.call(..) -> IQuery
db.sql(..) -> IQuery
public interface IQuery extends ICacheController<IQuery> {
long getCount() throws SQLException;
Object getValue() throws SQLException;
<T> T getValue(T def) throws SQLException;
Variate getVariate() throws SQLException;
Variate getVariate(Act2<CacheUsing,Variate> cacheCondition) throws SQLException;
<T extends IBinder> T getItem(T model) throws SQLException;
<T extends IBinder> T getItem(T model, Act2<CacheUsing, T> cacheCondition) throws SQLException;
<T extends IBinder> List<T> getList(T model) throws SQLException;
<T extends IBinder> List<T> getList(T model, Act2<CacheUsing, List<T>> cacheCondition) throws SQLException;
<T> T getItem(Class<T> cls) throws SQLException;
<T> T getItem(Class<T> cls,Act2<CacheUsing, T> cacheCondition) throws SQLException;
<T> List<T> getList(Class<T> cls) throws SQLException;
<T> List<T> getList(Class<T> cls,Act2<CacheUsing, List<T>> cacheCondition) throws SQLException;
DataList getDataList() throws SQLException;
DataList getDataList(Act2<CacheUsing, DataList> cacheCondition) throws SQLException;
DataItem getDataItem() throws SQLException;
DataItem getDataItem(Act2<CacheUsing, DataItem> cacheCondition) throws SQLException;
List<Map<String,Object>> getMapList() throws SQLException;
Map<String,Object> getMap() throws SQLException;
<T> List<T> getArray(String column) throws SQLException;
}